Linked Questions
848 questions linked to/from What is the most efficient way to deep clone an object in JavaScript?
171
votes
8
answers
216k
views
How to copy a Map into another Map? [duplicate]
How do I clone/copy a Map in JavaScript?
I know how to clone an array, but how do I clone/copy a Map?
var myArray = new Array(1, 2, 3);
var copy = myArray.slice();
// now I can change myArray[0] = ...
242
votes
8
answers
125k
views
(Deep) copying an array using jQuery [duplicate]
Possible Duplicate:
What is the most efficient way to clone a JavaScript object?
I need to copy an (ordered, not associative) array of objects. I'm using jQuery. I initially tried
jquery.extend({...
258
votes
4
answers
438k
views
Clone Object without reference javascript [duplicate]
I have a big object with much data. And i want to clone this in other variable. When i set some param of the instance B has the same result in the original object:
var obj = {a: 25, b: 50, c: 75};
var ...
193
votes
2
answers
215k
views
How to copy JavaScript object to new variable NOT by reference? [duplicate]
I wrote a quick jsfiddle here, where I pass a small JSON object to a new variable and modify the data from the original variable (not the new variable), but the new variable's data gets updated as ...
46
votes
3
answers
145k
views
Cloning objects TypeScript [duplicate]
I am working with Angular 2 with TypeScript. I have User Management component where I have table of whole users.
When any user in table is clicked then forms appeaer with his whole properties to ...
35
votes
1
answer
34k
views
Deep copying array of nested objects in javascript [duplicate]
I am trying to deep copy array of nested objects in javascript. My array look like this
var arr = [{name:"adam",age:"21"},
{name:"freddie",age:"35",children:[{name:"mercury",age:"25"}]},
{...
24
votes
4
answers
29k
views
How do I copy the data of an element with jQuery? [duplicate]
I need to copy data values from one element to another, but jQuery's clone() method doesn't clone the data. And I can't iterate over the data either:
element.data().each
because data() is a function ...
29
votes
5
answers
18k
views
How to clone js object? [duplicate]
Possible Duplicate:
What is the most efficient way to clone a JavaScript object?
How to clone js object with out reference like these:
{ ID: _docEl,
Index: next,
DocName: _el
}
Any ideas?
42
votes
3
answers
33k
views
Javascript deep copying object [duplicate]
Possible Duplicate:
What is the most efficient way to clone a JavaScript object?
I have an object like this:
User = {
name: "user",
settings: {
first: "1",
second: "2"
}
...
23
votes
3
answers
29k
views
How to clone props object and make it non-reactive [duplicate]
I have some form data which I share with children components through props. Now I want to clone the prop object and make it non-reactive. In my case I want the user to be able to modify the props ...
12
votes
4
answers
16k
views
object.assign does not copy functions [duplicate]
I have a common typescript class with some functions.
When I do this.selected = Object.assign({} as AssignedTestType, newTestType);
the selected instance does not own that functions which are in ...
2
votes
4
answers
7k
views
JavaScript: How to make a copy of a object? [duplicate]
I am trying to create a copy of object a, without having to manually enter its property's into object b. In this code, b simply refers to a. I want to create a new version of a, so that when I add a ...
10
votes
2
answers
7k
views
Create deep copy in angular 2 [duplicate]
How I can create deep copy in angular 2, I tried to use let newObject = Object.assign({}, myObject) but still myObject reflects all the changes done in newObject.
5
votes
3
answers
8k
views
How to push an object into an array without passing that object by reference? [duplicate]
So I have a property in a class called 'tiles' which contains information about a checkers board game's state. I'm trying to push this property to an array called 'moves' every time I make a legal ...
2
votes
4
answers
6k
views
how to create a copy of json object in javascript instead of a reference [duplicate]
i have testdata.js file with json test data as below:
testdata.js file:
module.exports =
{
createHost:
{
name : "System-001",
description: "Creating System",
}
...