How can we assign an object in Java Script??
For Example:-
-----------
If i create an object "obj1"
var obj1 = Object();
obj1.name = "hari";
and if i want to assign it to two objects "obj2" and "obj3"
with different names...
obj1.name = "gopi"
obj2 = new Object(obj1);
obj1.name = "raghu"
obj3 = new Object(obj1)
Now ob2.name become to "raghu" from "gopi". WHY?
how to solve the above problem?
Answer Posted / sandesh magdum
var obj1 = Object();
obj1.name = "hari";
obj1.name = "gopi";
obj2 = new Object(obj1);
//preserving name property of obj2 through obj4
var obj4=new Object();
obj4.name=obj2.name;
obj1.name = "raghu";
obj3 = new Object(obj1);
obj2=new Object(obj4);
alert("obj2 name="+obj2.name+" obj3 name="+obj3.name)
Is This Answer Correct ? | 5 Yes | 3 No |
Post New Answer View All Answers
What is the difference between synchronous postback and asynchronous postback? : asp.net ajax
Whats with the -alpha in the install instructions?
How can we detect asynchronous partial page postbacks?
When should I use a java applet instead of ajax?
Explain the updatepanel control? : asp.net ajax
Who is using ajax?
What are the security issues with ajax?
Does this mean adaptive path is anti-flash?
Does java have support for comet style server-side push?
What are ajax limitations?
What are the different controls of asp.net ajax? : asp.net ajax
What is the work of the conformonformsubmit property in the confirmbuttonextender control? : asp.net ajax
What is the difference between javascript and ajax?
What are different readystate in ajax?
Is ajax a browser-dependent or a browser-independent script?