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?

Answers were Sorted based on User's Feedback



How can we assign an object in Java Script?? For Example:- ----------- If i create an object &q..

Answer / 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

How can we assign an object in Java Script?? For Example:- ----------- If i create an object &q..

Answer / rajesh

I maynot give the exact reason..but root cause may be
because of...

As you know the javascript is just parsed from top to
bottom. It won;t execute as long as you run the app.
While parsing it just holds the reference and checks for
syntactical errors.

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More AJAX Interview Questions

How does html_ajax compare with the xajax project at sourceforge?

0 Answers  


How can we detect asynchronous partial page postbacks?

0 Answers  


Methods of consuming web services in AJAX?

0 Answers   QuestPond,


Is javascript knowledge is required to do Ajax?

1 Answers  


List some advantages and disadvantages of using ajax.

0 Answers  






Did adaptive path invent ajax? Did google? Did adaptive path help build google's ajax applications?

0 Answers  


what is meant by AJAX and its purpose?

7 Answers  


What is update panel?

1 Answers  


Is it possible to use fileupload control within the update panel?

0 Answers  


Why does html_ajax hang on some server installs?

0 Answers  


What are ajax limitations?

0 Answers  


What is the difference between RegisterClientScriptBlock, RegisterClientScriptInclude and RegisterClientScriptResource?

1 Answers   Clavax Technologies,


Categories