Saturday, 15 March 2014

javascript - concat with object in same list -



javascript - concat with object in same list -

this question has reply here:

self-references in object literal declarations 12 answers

i want concatenate contents of 1 object another, within same list/command:

var myvar = { options: { option1: "foo", option2: "bar", option3: "it's not kung "+options.option1+", kung fu", } }

this doesn't work, hints on i'm doing wrong here?

options.option1 not defined yet @ point using it.

var myvar = { options: { option1: "foo", option2: "bar" } }; myvar.options.option3 = "it's not kung "+myvar.options.option1+", kung fu";

should work intended.

note not dynamic (option3 not alter on changes on option1). if want dynamic behaviour, find solutions here: self-references in object literal declarations

javascript object concatenation

No comments:

Post a Comment