What is object cloning

Answer Posted / me

A bit of background information. Because the way memory
works (long story), an object consists of two things, the
reference which is basically a pointer, or a label that is
used to access the object, and the actual object data,
which is stored elsewhere (search Google for explanations
on memory stacks and heaps).

If you would simply copy an object, you would only copy the
reference. So what you end up with, are two references that
point to exactly the same data. When you change the
original object, the copy object gets changed as well, and
visa versa.

If that's not what you want, you have to clone the object,
which means you actually create a new object in memory,
that holds a copy of the data of the original object, and
you also create a new reference that points to this new
object.

When you then change some value in the original object, the
copy object stays unchanged.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what are the difference unescape() and escape() functions?

724


Are java and javascript the same?

723


what difference between args.length and args.length() in command line argument?

1991


What is an example of javascript?

618


What are the application of javascript?

685


What does three dots mean in texting?

685


What will be the output of the following statements?

696


Explain the role of deferred scripts in javascript?

684


What is stack in javascript?

692


What are ‘settimeout()’?

765


what are the differences between as2 and as3?

3121


Explain escape() in javascript?

679


What are self Executing Functions?

802


What is dataview in javascript?

662


I need project details about WEB CONTENT FILTERING USING NEURAL NETWORKS and how to explain it....plz help me in this topic.....

1886