new(Date)和new Date()之间有什么区别?

编程入门 行业动态 更新时间:2024-10-27 10:20:49
本文介绍了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()之间有什么区别?

本文发布于:2023-11-07 04:11:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1565542.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有什么区别   Date

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!