In the second for loop, you need to initialize your i variable.
Consider:
var items = ["string", false, null, 0, "", {}, []];
The first loop will go through the entire array. However, the second condition of the loop will evaluate the value assigned to the element. The boolean value of this part will be:
!!(item = items[i])
valid values ββsuch as null , 0 , false , "" (empty string) and undefined will evaluate to false and break. In the array above, you exit the for loop when the element is set to false
source share