json in array -> overlap problem

P

pistacchio

hi to all!

having a problem with javascript, i've stripped the script down to a
few lines in order to post it here asking for help.

<code>
var objs = new Array();
obj = {
parameter : ''
}

objs[0] = obj;
objs[0].parameter = "apple";

objs[1] = obj;
objs[1].parameter = "banana";

alert(objs[0].parameter);
</code>

i insert the json object obj into the array and change the parameter.
now, i expect the alert to return "apple", while i keep getting
"banana", as, in some unpredictable way, the value has been
overlapped.
any help?
tia - gustavo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,416
Latest member
LionelQ387

Latest Threads

Top