Coercions can be counter-intuitive, use same-type comparisons
· ☕ 1 min read
Coercions are useful and almost intuitive, but beware of pitfalls.
Consider below block of code -
1 const x = 42; Numbers greater than 0 and not undefined are generally considered truthy.
So, following is understandable -
1 2 if (x) console.log("found the answer"); // found the answer But, you will be surprised if you do this -