When should literal notation be used over constructor when creating a new object?


I don't understand when to use var myObj = {} and when to use var myObj = new Object(); Can somebody please explain real quick?


*Wrong answer*....


What is the difference between assigning a list of properties and assinging the type Object? The first option seems to be the shortcut to me. Correct me if I am wrong.


Oh I see now, ignore my first answer.

With var myObj = {} you define a new object named myObj. When using var myObj = new Object(); you're creating an object from an already defined class.

I could be wrong, I'm not very familiar with the concepts of object-oriented JavaScript.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.