Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

JavaScript: Shorthand to toggle a non-boolean value

$
0
0

Is there a better shorthand to toggle foo?

type Foo = 'ON' | 'OFF';let foo: Foo = 'ON';const toggleFoo = () => {  foo = foo === 'ON' ? 'OFF' : foo;};toggleFoo();

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>