Difference between Array.slice and Array().slice

后端 未结 6 1099
醉酒成梦
醉酒成梦 2020-12-12 21:04

I am going through John Resig\'s excellent Advanced javascript tutorial and I do not thoroughly understand what\'s the difference between the following calls: (please note t

6条回答
  •  Happy的楠姐
    2020-12-12 21:45

    I believe Array is the type and Array() is the constructor function.

    Messing around in FireBug:

    >>> Array === Array()
    false
    
    >>> Array.constructor
    Function()
    
    >>> Array().constructor
    Array()
    

提交回复
热议问题