Skip to content

Instantly share code, notes, and snippets.

@siddharth-sunchu
Created June 26, 2021 22:20
Show Gist options
  • Save siddharth-sunchu/92e7ff4f10bc432cb49d8f8e7ef103a9 to your computer and use it in GitHub Desktop.
Save siddharth-sunchu/92e7ff4f10bc432cb49d8f8e7ef103a9 to your computer and use it in GitHub Desktop.
console.log("********Nested ARRAYS********");
const c = [1, 2, [3, 4]];
const d = JSON.parse(JSON.stringify(c)); // => JSON Methods
console.log('c => ', c);
console.log('d => ', d);
/*
********Nested ARRAYS********
c => [ 1, 2, [ 3, 4 ] ]
d => [ 1, 2, [ 3, 4 ] ]
*/
d[0] = 0;
d[2][1] = null;
console.log("---------After modification---------");
console.log('c => ', c);
console.log('d => ', d);
/*
---------After modification---------
c => [ 1, 2, [ 3, 4 ] ]
d => [ 0, 2, [ 3, null ] ]
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment