MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/192tn4/common_javascript_gotchas/c8kbzch/?context=3
r/javascript • u/stevekwan • Feb 23 '13
50 comments sorted by
View all comments
3
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?
[object Object]
3 u/niallpaterson Feb 23 '13 Use the first ({}) because "Object" in "new Object" can be redefined.
Use the first ({}) because "Object" in "new Object" can be redefined.
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?