new(Date)和new Date()之间有什么区别? [英] what is the difference between new(Date) and new Date()?
本文介绍了new(Date)和new Date()之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在javascript中,新建对象的典型方法是这样做: new Date()
。但你也可以这样做: new(Date)
。
In javascript, the typical way to new up an object is by doing it like this: new Date()
. But you can also do this: new (Date)
. What is the difference and advantages of doing it the latter way?
推荐答案
没有什么区别。
new
运算符接受函数引用。
与任何其他运算符一样,操作数可以有括号。
The new
operator takes a function reference.
Like any other operator, the operand can have parentheses.
在新
表达式之后的()
参数是可选的。
The ()
after a new
expression with no arguments are optional.
但是,如果括号中有更多复杂的表达式,它们可以更改优先顺序,例如此答案。
However, if you have more a complicated expression inside the parentheses, they can change precedence ordering, such as in this answer.
这篇关于new(Date)和new Date()之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文