!arr would be wrong too. Array is an Object and any object is true-ish.
!arr
Because in JavaScript [] == [] returns false - you cannot directly compare arrays. I suggesting reading this or this for information why. If you are checking an empty array, I suggest using Boolean, e.g. if !arr or arr.length==0.
[] == []
Edit: Fuck, jinx beat me to it again :P
Wrong: arr==[] Right: arr.length==0
arr==[]
arr.length==0
Loading collection data...
!arr
would be wrong too. Array is an Object and any object is true-ish.Because in JavaScript
[] == []
returns false - you cannot directly compare arrays. I suggesting reading this or this for information why. If you are checking an empty array, I suggest using Boolean, e.g. if !arr or arr.length==0.Edit: Fuck, jinx beat me to it again :P
Wrong:
arr==[]
Right:
arr.length==0