Array()vs new Array() [英] Array() vs new Array()
本文介绍了Array()vs new Array()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么区别(如果有的话)
What is the difference (if there is any) between
x = Array()
和
x = new Array()
我应该使用哪一个?
推荐答案
规范说:
当
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()vs new Array()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文