开发者

Are the following statements in javascript equivalent? [duplicate]

开发者 https://www.devze.com 2023-03-29 06:16 出处:网络
This question already has answers here: 开发者_运维知识库 Closed 11 years ago. Possible Duplicates:
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

精彩评论

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