I came across something that I had never seen before, and I like it. check the examples below:
var arr = ['un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept']; for(var i = 0; arr[i]; i++){ console.log( arr[i] ); }
instead:
for(var i = 0; i < arr.length; i++){ console.log( arr[i] ); }
But both of them achieve the same result, which displays a list of arrays.
My question is, what is the difference (or similarity) between using "arr [i]" and "arr.length" in a declaration for a loop ?
Many thanks
Shaoz source share