als antwoord op
All the things that are falsy, including an array with one item that is falsy itself, which gets recursive.
All the things that are falsy, including an array with one item that is falsy itself, which gets recursive.
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
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
Oh Javascript.