I found that both the Array
Object and Array.prototype
have the length
property. I am confused on using the Array.length
Array.length
provides the number of declared parameters in Array
function definition. Since Array function definition has only one size
parameter, hence it will return 1 irrespective of your array content.
Array.prototype.length
provides the number of elements in array data. It is dependent on the array content.
var arr=new Array();
console.log(Array.length);//returns 1
console.log(arr.length);//returns 0 as array has 0 elements