Using object lists


Arrays and Obects in Js #11

It keeps saying SyntaxError: Unexpected token [

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


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: = "Charlie";

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


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?


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