开发者

Are the following statements in javascript equivalent? [duplicate]

This question already has answers here: 开发者_运维知识库 Closed 11 years ago.

Possible Duplicates:

Is there a reason not to use new Object() in JavasScript?

Create an empty object in JavaScript with {} or new Object()?

In javascript, are the following two statements equivalent?

var c = new Object();

var c = {};


Yes. From §11.1.5 Object Initialiser:

The production ObjectLiteral : { } is evaluated as follows:

Return a new object created as if by the expression new Object() where Object is the standard built-in constructor with that name.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜