比如:
var a = Array(); 和 var aa = new Array();
var b = Object(); 和 var bb = new Object();
高洛峰2017-04-11 12:39:26
根据
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()
是等同的。
迷茫2017-04-11 12:39:26
第一种是构造函数式,即通过new运算符调用构造函数Function来创建函数
第二种不是实例化,只是调用函数把返回值赋给变量。
详细的可以看下javascript中使用new与不使用实例化对象的区别的介绍,希望对你有帮助