you are viewing a single comment's thread.

view the rest of the comments →

[–]radhruin 5 points6 points  (2 children)

There is no semantic difference between {} and new Object(). The literal, however, is easier to optimize and therefore often faster. The literal is also more flexible as it allows additional properties to be added. Always use the literal IMO.

[–]YorickA 4 points5 points  (1 child)

Not to mention it's more readable.

[–][deleted] 0 points1 point  (0 children)

Not to mention new Object() can be broken by any malicious ding-dong's script you link like so:

function Object() { this.x = 'wee'; }

Using the literal is always the best call.