How to use type coersion in Javascript
Issue #391
People who make fun of Javascript probably don’t understand implicit type coersion and when to use triple equal. Javascript is very unexpected, but when we work with this language, we need to be aware.
- Coercion–Automatically changing a value from one type to another.
- If x is Number and y is String, return x == ToNumber(y)
- If x is String or Number and y is Object, return x == ToPrimitive(y)
- Empty array becomes empty string