I’m really confused by this. If I do something like this:
[1].slice(1)
it returns an empty array (in the chrome interactive console). But if I compare:
[1].slice(1) === []
it’s always false. So my Question is, what does [1].slice(1) really return?
I’m really confused by this. If I do something like this: [1].slice(1) it returns
Share
===compares objects by references.You’re comparing two different array objects which are both empty.
If you want to check whether an array is empty, check whether
.length === 0.