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


#1

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


#2

*Wrong answer*....


#3

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.


#4

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.


#5

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