4 ms·
So, why use two bytes for '!0' when just '1' works?
by djbusby 3y ago
So, why use two bytes for '!0' when just '1' works?
- tinyhitman 3y agoIts not strictly the same. '1' is a number whereas '!0' is a boolean.
- ilyt 3y agoI hate that language a bit more now
- hn92726819 3y agoBoth 1 and true are truthy, but not the same. That would work if the variable was only ever used in if(x), conditions, etc. Stringifying won't produce the same value either when passing values as well.
- cmg 3y agoBecause 1 !== true and 0 !== false in JavaScript: const index = "Hello HN".indexOf("H") console.log(index); >> 0 index == false >> TRUE index === false >> FALSE