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
Will html_ajax integrate with other javascript ajax libraries such as scriptaculous?
Explain what is polling in ajax?
What are the new features included in the microsoft ajax library? : asp.net ajax
How ajax is different?
What is the importance of client-side libraries? : asp.net ajax
How can you debug asp.net ajax applications?
What is json? : asp.net ajax
Which control you need to place on the page to show loading image?
What are Ajax applications?
Explain Ajax polling?
What will happen with click of browser "back" button among asynchronous requests?
How do I provide internationalized ajax interactions?
What are the security issues with ajax?
What are the browser versions that ajax is compatible with?
What is the purpose of xmlhttprequest?