Bayu’s counter: two things, three ways to compare. Watch == rewrite the slips before it compares, then guess what all three say about two boxes with the same…
if (input == 0) passes for empty text, '0', false and []. Bugs like these throw no error; they quietly make the logic wrong. Most style guides and the eqeqeq lint rule ask for ===, with one exception: x == null.
== converts types first; === never does
if (x == true) to check for truthy '2' == true is false, because true becomes 1. Write if (x) when you mean truthy, or x === true when it must be the boolean.NaN with === NaN === NaN is always false. Use Number.isNaN(x).[1] === [1] is false: the boxes (references) are compared, not the contents. For contents, compare element by element or use a deep-equal helper.'1' with 1 == turns the text '1' into the number 1 first, so true. === says false because the types differ.null with undefined The one mixed pair where == is useful: x == null catches both at once.NaN with NaN == and === both say false. Only Object.is says true.[] with false == says true after three conversions: watch the slips being rewritten one by one.