0

So i just found out [0] == true is false, and [0] === true is also false, so i assumed [0] should be evaluated to false. But when I am writing

if([0]) {
   console.log("hi");
}

prints "hi" That happens because Boolean([0]) returns true. But i think it should have returned false. What am I thinking wrong here?

Abhishek Bera
  • 121
  • 1
  • 5

1 Answers1

1

JS engine interpretation is that it is a non empty array. Hence, a truthy value in If condition.