Today learned that CoffeeScript doesn’t allow loose equality, so, whenever you
=== and that’s by design!
Loose equality (“double equals”) compares two values for equality, after converting both values to a common type. After conversions (one or both sides may undergo conversions), the final equality comparison is performed exactly as === performs it. Loose equality is symmetric: A == B always has identical semantics to B == A for any values of A and B (except for the order of applied conversions).
Why CoffeeScript doesn’t allow it?
Because the == operator frequently causes undesirable coercion, is intransitive, and has a different meaning than in other languages, CoffeeScript compiles == into ===, and != into !==. In addition, is compiles into ===, and isnt into !==.
And what if you need it?
Perform type conversion explicitly
Here is few examples:
Or with the old good JS functions:
Prefer loose equality?
No problem, you can use embedded JS like this:
Which ever approach you choose, the only important thing is to make sure that you know what you’re doing! ;)