49
rated 0 times
[
56]
[
7]
/ answers: 1 / hits: 80760
/ 13 Years ago, wed, march 30, 2011, 12:00:00
Empty arrays are true but they're also equal to false.
var arr = [];
console.log('Array:', arr);
if (arr) console.log(It's true!);
if (arr == false) console.log(It's false!);
if (arr && arr == false) console.log(...what??);
I guess this is due to the implicit conversion operated by the equality operator.
Can anyone explain what's going on behind the scenes?
More From » javascript