This question already has an answer here:
- Self-references in object literals / initializers 21 answers
I have an array of variables. And I want one variable to equal the previous one. For example:
var myVars = {
var1: "test",
var2: var1
};
alert(myVars.var2);
//output: var1 is not defined
Any thoughts? I'm sure this is some sort of variable scope limitation. I would like to hear otherwise. Thanks in advance.