OneCompiler

Finding array of length without using length method in javascript

242

var a = [10,20,30,40];

function arrayLen(){
let length = 0;

while (a[length]!==undefined){
length++;
}
return length;
}

console.log(arrayLen(a));