2 ms·
This is the ultimate conditional syntax: if (x === 1) console.log(“it’s 1”) The “if” bothers me though, be nice not to have it.
by andrewstuart 2y ago
This is the ultimate conditional syntax:
if (x === 1) console.log(“it’s 1”)
The “if” bothers me though, be nice not to have it.
- rlkf 2y ago(x === 1) && console.log("it's 1") Note that you've saved exactly no keystrokes, although this is composable into expressions (if you are using some Javascript-derivative; in ML it would typically already be using the if-form).
- eacnamn 2y ago((x == 1)) && printf 'it'"'"'s 1\n' although I'm not sure how useful this actually is, but it is a nice-to-know
- andrewstuart 2y agoor x === 1 && console.log("it's 1");