为了账号安全,请及时绑定邮箱和手机立即绑定

JS 对象和数组的创建使用new和不使用new有什么区别呢?

JS 对象和数组的创建使用new和不使用new有什么区别呢?

叮当猫咪 2018-10-12 14:11:06
比如:var a = Array(); 和 var aa = new Array();var b = Object(); 和 var bb  = new Object();
查看完整描述

1 回答

?
蝴蝶刀刀

TA贡献1801条经验 获得超8个赞

根据EMACScript标准

The Array constructor is the %Array% intrinsic object and the initial value of the Array property of the global object. When called as a constructor it creates and initializes a new exotic Array object. When Array is called as a function rather than as a constructor, it also creates and initializes a new Array object. Thus the function call Array(…) is equivalent to the object creation expression new Array(…) with the same arguments.

调用Array()new Array()是等同的。


查看完整回答
反对 回复 2018-11-26
  • 1 回答
  • 0 关注
  • 1311 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信