I did a series of tests for different array values:
Tests:
x === 0
x === ''
x === false
x === undefined
x === NaN
x === null
x === []
x === {}
x == 0
x == ''
x == false
x == undefined
x == NaN
x == null
x == []
x == {}
Result:
if x is either:
[NaN]
[false]
it fails all tests.
if x is either:
[null]
[]
[[]]
[[[yep, no matter how deep]]]
[undefined]
['']
it passes:
x==0
x==''
x==false
if x is either:
[0]
[{}]
it passes
x==0
x==false
Am I missing something? Is there something an empty array [] strictly equal to (===)?
Also, for these values: [NaN],[false], [null], [], [[]], [undefined], [''], [0], [{}], only [].length is equal to 0
What are the best practices on how to check if an array is empty []? If there are competing best practices, in which situations is it best to use them?
What are the best practices on how to check if an array is empty, how aboutarray.length==0?