De eerste pepernoot van het jaar is binnen.
So, yesterday I learned that [] == []
is false
in Javascript. Today my adventures with arrays lead me to this:
const coffees = ['espresso', 'latte', 'filter']
console.log(
'filter' in coffees,
'cappuchino' in coffees,
'espresso' in coffees
)
// => true, false, false
Some other weird things about falsy Javascript:
false == false
0 == false
[] == false
"" == false
"0" == false
"\t" == false
[] == false
["0"] == false
[[["0"]]] == false
[[[1 - 1]]] == false
[[[{}.foobar]]] == false
[[[`\t ${[].length} \t`]]] == false
// BUT
[false] != false