The only good way to test if an array is empty is with arr.length.
Let see different case.
if(arr === true) will always be false since array is not a boolean.
if(arr !== false && arr !== true) will return true for the same reason!
if(arr) will return true or false, it depend if the array is set. If the var arr = [], it will return true, but it is an empty array.
In fact, even if the var is not an array, it will return true.
if(arr[0]) will return true if there is a value in the cell with the index 0. Even there, it doesnt mean it is empty, because you can set a cell like that var arr=[]; arr[1] = 'value' and arr[0] will return false because it is not set, but the array have a length of 2 (with one cell).
Finally, the best way to see if an array is empty is like that : if(arr && arr.length).
checking if arr exist not needed if you know that you have created the array, but else, it will prevent any errors. Then, you check the length of the array and if you haven't changed the value like that : arr.length = 1000, it will tell you if the array is empty.
arr == truealways false? Whether empty or not?if (arr)case?undefined. JavaScript doesn't have to traverse the array to determine its length. Note thatif(arr)will always betrueifarris an array, empty or not. You need to testarr.length(and possibly useArray.isArray(arr)) to test whetherarris an empty array.