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

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 关注
  • 1334 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号