Linked Questions

171 votes
8 answers
216k views

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] = ...
sazr's user avatar
  • 26.2k
242 votes
8 answers
125k views

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({...
morgancodes's user avatar
  • 25.3k
258 votes
4 answers
438k views

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 ...
Enzo's user avatar
  • 4,191
193 votes
2 answers
215k views

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 ...
Prusprus's user avatar
  • 8,085
46 votes
3 answers
145k views

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 ...
miechooy's user avatar
  • 3,442
35 votes
1 answer
34k views

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"}]}, {...
user2912611's user avatar
24 votes
4 answers
29k views

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 ...
MDCore's user avatar
  • 18.2k
29 votes
5 answers
18k views

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?
Harold Sota's user avatar
  • 7,586
42 votes
3 answers
33k views

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" } ...
Matteo Pagliazzi's user avatar
23 votes
3 answers
29k views

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 ...
A.C's user avatar
  • 513
12 votes
4 answers
16k views

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 ...
Pascal's user avatar
  • 12.9k
2 votes
4 answers
7k views

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 ...
James's user avatar
  • 1,897
10 votes
2 answers
7k views

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.
Dheeraj Agrawal's user avatar
5 votes
3 answers
8k views

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 ...
siddube's user avatar
  • 135
2 votes
4 answers
6k views

i have testdata.js file with json test data as below: testdata.js file: module.exports = { createHost: { name : "System-001", description: "Creating System", } ...
saradhi ramakrishna's user avatar

15 30 50 per page
1
2 3 4 5
57