JavaScript
array.length in for-loop

by Benny Neugebauer

var array = ['A', 'B', 'C'];

for (var i = 0, length = array; i < length; i++) {
  console.log(array[i]);
}

var array = ['A', 'B', 'C'];

for (var i = 0; i < array.length; i++) {
  console.log(array[i]);
}

Variant A has a typo, length = array ๐Ÿ˜›

Maxim Baz

Sign in to comment!