What's the difference between Array(1) and new Array(1) in JavaScript?

前端 未结 3 1633
暗喜
暗喜 2020-12-01 04:33

I just started thinking about this, but couldn\'t get any differences to expose themselves whilst mucking around in jsFiddle.

var a = new Array(1),
    b = A         


        
3条回答
  •  醉话见心
    2020-12-01 04:50

    According to Javascript: The Definitive Guide (5th Edition), page 602, "When the Array() constructor is called as a function, without the new operator, it behaves exactly as it does when called with the new operator."

提交回复
热议问题