I found that both the Array Object and Array.prototype have the length property. I am confused on using the Array.length property. How do you use it?
Console.log(Object.getOwnpropertyNames(Array));//As per Internet Explorer
outputs:
length,arguments,caller,prototype,isArray,
Prototype and isArray is usable but how do you use the length property?
Array is a constructor function.
All functions have a length property that returns the number of declared parameters in the function definition.
Array.length is how many arguments the function Array() takes and Array.prototype.length is an instance method that gives you the length of your array. When you check ['foo'].length you're actually checking Array.prototype.length with the this argument being your array ['foo']
var myArray = ['a','b','c']
console.log(myArray.length); //logs 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With