11/17 Creating a New Object



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

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


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";


me["name"] = "Mari";


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