Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 is let keyword in typescript?

979


What is scope variable in javascript?

1039


How do you change the style/class on any element using javascript?

909


Is javascript necessary?

834


What are math constants and functions using javascript?

989


What Does JavaScript Void(0) Mean?

918


What is the difference between HTMLCollection and NodeList?

1052


What kind of conditional statements does JavaScript support?

954


How to get the type of arguments passed to a function?

895


How do you declare in javascript?

868


How do you know if a set of points is a function?

918


How do I write script-generated content to another window?

928


How to use one javascript function for multiple input fields?

2031


What is the difference between the operators ‘==‘ & ‘===‘?

965


How generic objects can be created?

916