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.
I'd avoid using new Object(). {} is preferred. The only reason I used new Object() is because I felt it would be more understandable to people coming in from another language.
3
u/wkdown Feb 23 '13
Quick question: which is the 'proper' way to instantiate an object?
var obj1 = {};or
var obj2 = new Object();Both return
[object Object]and typeof "object". Is one better than the other?