Using object lists


#1


Arrays and Obects in Js #11


It keeps saying SyntaxError: Unexpected token [


var me = {
    me["name"] = "Joshua",
    me["age"] = 14
};


#2

you seem to be confusing the Literal notation:

var myObj = {
    type: 'fancy',
    disposition: 'sunny'
};

and the constructor notation:

var myObj = new Object();

and then to add property's for a constructor object you can either use the associative array notation (like you have):

myObj["name"] = "Charlie";

or the object notation:

myObj.name = "Charlie";

but be careful not to mix the constructor notation and the literal notation.


#4

sorry, i didn't see you had object constructor, you are using the literal notation, use the object constructor.

You withdraw your post, does this mean you solved it?


#5

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