If statement and toBoolean


Why [1][1] is undefined and will be evaluated false, it is an array so it should be true?

What do you get if the expression evaluated is changed to [1][0]?

[1] is an array that contains only one value at index 0. Asking [1] for index 1, which is what happens when doing [1][1] results in undefined, because the array has no index 1 location.

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.