Saltar al contenido
← volver

JavaScript Has a Weird Trick: [] == false Is True

DEV · dev.to Publicado:

JavaScript Has a Weird Trick: [] == false Is True The output is: Wait… how can an empty array equal false? JavaScript converts false to 0, and the empty array to an empty string, which becomes 0 when converted to a number. But === checks both value and type without performing this kind of type conversion. An array and a boolean are different types. Can you predict all three outputs before running the code?

Leer original →

Más de DEV