3 ms·
Tangential question, what does the !! operator do in: const supported = !! self.WebAssembly;
by dandare 6y ago
Tangential question, what does the !! operator do in:
const supported = !! self.WebAssembly;
- test1235 6y agocoerces the object to a boolean
- dandare 6y agoOf course! :)
- deleted 6y ago[deleted]
- simlevesque 6y ago! Is the operator but it is used twice.
- XCSme 6y agoIt's just the not "!" operator twice. The first NOT operator (from right to left) casts the following operand to the boolean primitve type and negates the value. The second NOT operator reverses the truth value of the boolean, in order to regain the original truthiness. !self.WebAssembly; -> false if self.WebAssembly is truthy (eg. object exists), true otherwise !!self.WebAssembly; = !(!self.WebAssembly;) = !(false|true) -> true if WebAssembly is defined, false otherwise.