Quickly convert any value to a boolean by using double negation.
let truthyValue = !!1; // true
let falsyValue = !!0; // false
NOTE
- 1 can be any
true
value - 0 can be any
false
value
For more refer
- which are the true values
- & false values in javascript
- https://javascript-equality-table.vercel.app/if-condition
Learn from: https://dev.to/mmainulhasan/30-javascript-tricky-hacks-gfc
Top comments (0)