
Copying Arrays (deep and shallow) - Beau teaches JavaScript
video description
Date: 2022-03-14
Related videos
Comments and reviews: 5
Robert
I used this array to test:
let deepArray = [true, undefined, false, null, [-freeCodeCamp-]];
JSON changed the undefined to null during the copy. But isn't best practice to define empty data as null rather than undefined? And you probably would be testing if the data was undefined before pushing it on to your array anyways. (Or at least you should be.)
reply
I used this array to test:
let deepArray = [true, undefined, false, null, [-freeCodeCamp-]];
JSON changed the undefined to null during the copy. But isn't best practice to define empty data as null rather than undefined? And you probably would be testing if the data was undefined before pushing it on to your array anyways. (Or at least you should be.)
reply
Yaniv
// arr = [1,2,3]
// arr2 = arr.map(x=>x)
// console.log(arr2);
// arr = [1,2,3]
// let arr2 = JSON.parse(JSON.stringify(arr))
// console.log(arr2)
// arr = [1,2,3]
// arr2= arr.slice(0);
// console.log(arr2)
// arr = [1,2,3]
// arr2= []
// for(let i = 0; i
reply
// arr = [1,2,3]
// arr2 = arr.map(x=>x)
// console.log(arr2);
// arr = [1,2,3]
// let arr2 = JSON.parse(JSON.stringify(arr))
// console.log(arr2)
// arr = [1,2,3]
// arr2= arr.slice(0);
// console.log(arr2)
// arr = [1,2,3]
// arr2= []
// for(let i = 0; i
reply
Reehana
When copying array of json data into new array using speard operator it's muting original data. Speard operator fails over here. I used to resolve this issue by using lodash --
reply
When copying array of json data into new array using speard operator it's muting original data. Speard operator fails over here. I used to resolve this issue by using lodash --
reply
itech
your explanations really need some work. there has been a lack of clarity in at least half of your videos that i've watched so far
reply
your explanations really need some work. there has been a lack of clarity in at least half of your videos that i've watched so far
reply
Vinycius
Dude... I'm already loving you so much. I spent an hour racking my brains with this at work and now it's finally settled.
reply
Dude... I'm already loving you so much. I spent an hour racking my brains with this at work and now it's finally settled.
reply
Add a review, comment
Other channel videos















