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


Please Help Members By Posting Answers For Below Questions

What is the difference between synchronous postback and asynchronous postback? : asp.net ajax

660


Whats with the -alpha in the install instructions?

512


How can we detect asynchronous partial page postbacks?

512


When should I use a java applet instead of ajax?

549


Explain the updatepanel control? : asp.net ajax

507






Who is using ajax?

573


What are the security issues with ajax?

560


Does this mean adaptive path is anti-flash?

582


Does java have support for comet style server-side push?

535


What are ajax limitations?

492


What are the different controls of asp.net ajax? : asp.net ajax

512


What is the work of the conformonformsubmit property in the confirmbuttonextender control? : asp.net ajax

540


What is the difference between javascript and ajax?

551


What are different readystate in ajax?

585


Is ajax a browser-dependent or a browser-independent script?

527