11/17 Creating a New Object


#1

https://www.codecademy.com/en/courses/javascript-beginner-en-9Sgpi/2/3?curriculum_id=506324b3a7dffd00020bf661#


I am getting a syntax error and I can't understand why.

var me = {new object();
    me["name"]: "Mari",
    me.age: 16};


#2

This is how you use the object constructor, please.

var me = new Object ();
object.key = value;
object["key"] = value;

In this instance, for example, your object is me, so you can do.

me.name = "Mari";

//OR

me["name"] = "Mari";

#3

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