Array() 与 new Array() [英] Array() vs new Array()
本文介绍了Array() 与 new Array()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么区别(如果有的话)
What is the difference (if there is any) between
x = Array()
和
x = new Array()
我应该使用哪个?
推荐答案
spec 说:
当 Array
作为函数而不是构造函数被调用时,它会创建并初始化一个新的 Array 对象.因此,函数调用 Array(…)
等效于具有相同参数的对象创建表达式 new Array(…)
.
When
Array
is called as a function rather than as a constructor, it creates and initialises a new Array object. Thus the function callArray(…)
is equivalent to the object creation expressionnew Array(…)
with the same arguments.
这篇关于Array() 与 new Array()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文