How do you give variables reference in javascript?
- by Eric
I want to give variables reference in javascript.
For example, I want to do:
a=1
b=a
a=2
and have b=2, and change accordingly to a.
Is this possible in javascript?
If it isn't is there a way to do like a.onchange = function () {b=a}?
What I wanted to do was make a function like makeobject which make an object and puts it in an array and than returns it like
function makeobject() {
objects[objects.length] = {blah:'whatever',foo:8};
}
so than I could do
a=makeobject()
b=makeobject()
c=makeobject()
and later in the code do
for (i in objects) {
objects[i].blah = 'whatev';
}
and also change the values of a,b and c