0

I thought [] should return false when checked by !![] but I tried it and it returns true.

Is it correct or does it depend on a browser?

Sergei Basharov
  • 51,276
  • 73
  • 200
  • 335
  • 3
    with google I get a million answers on this: https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=javascript+empty+array+truthy did you try google? – caramba Oct 05 '15 at 15:10
  • 1
    http://stackoverflow.com/questions/5491605/empty-arrays-seem-to-equal-true-and-false-at-the-same-time – Stelium Oct 05 '15 at 15:11
  • 1
    `![].length && "empty array"` – lshettyl Oct 05 '15 at 15:12
  • 1
    http://stackoverflow.com/questions/19146176/javascript-empty-array-evaluates-to-true-in-conditional-structures-why-is – j08691 Oct 05 '15 at 15:12
  • look at this. I've tried bing: they also have answers: https://www.bing.com/search?q=javascript+empty+array+truthy&go=Senden&qs=n&form=QBLH&pq=javascript+empty+array+truthy&sc=0-11&sp=-1&sk=&ghc=1&cvid=6738d1e962ed4e7f891385d50858dfd2 – caramba Oct 05 '15 at 15:14
  • PHP programmers may expect intuitively [] (and '0') to be false, but nope - that's javascript, those are true. – user1702401 Oct 05 '15 at 15:14

0 Answers0