I\'m new to JavaScript and I\'m trying to learn it from internet resources. While I\'m aware that there will plenty of cr*p material, one thing most people seemed to agree i
With non-strict comparison (==) if the operands are not of the same type, they will be casted/coerced and strictly compared, with first preference being to numbers if either operand is a number or boolean (MDN).
So true == 2 evaluates to Number(true) === 2 which is 1 === 2, which is false.
Of course you can always force things to compare as you want them to, which is explicit and can solve hard-to-find problems later on:
true === Boolean(2) is true.