3 ms·
OT but what's up with all the double exclamation marks in the code? https://github.com/callumprentice/callumprentice.github.io/blob/master/apps/flight_stream/j
by Kiro 12y ago
OT but what's up with all the double exclamation marks in the code?
https://github.com/callumprentice/callumprentice.github.io/blob/master/apps/flight_stream/js/Detector.js https://github.com/callumprentice/callumprentice.github.io/b...
- masklinn 12y agoConverts a value to a true boolean: if `a` is truthy (is assimilated to `true` in boolean contexts), `!!a` will be `true` rather than the original value. It's equivalent to but much shorter than `Boolean(a)`, and just as readable if you know the idiom.
- film42 12y agoDouble exclamation marks force a true value, as opposed to a truthy one. For example: SomethingTruthy => TruthyThing !SomethingTruthy => False !!SomethingTruthy => True
- benihana 12y agoEssentially, it returns whether a value exists or not
- callumprentice 12y agoThanks for explanations. Also worth pointing out that that code is part of Three.js - an amazing library that makes it very straightforward to do things like this.