zoukankan      html  css  js  c++  java
  • Array.length vs Array.prototype.length

    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?

    Answer:

    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
    

      

  • 相关阅读:
    Sword 17
    Sword 16
    Sword 15
    Sword 14-II
    Sword 14-I
    Sword 13
    Sword 11
    Sword 10-II
    Sword 10
    【python+selenium】三种等待方式
  • 原文地址:https://www.cnblogs.com/oxspirt/p/6069177.html
Copyright © 2011-2022 走看看