Created
April 8, 2020 10:02
-
-
Save cssmatter/f0d864233dd110ae19068fa29f563ed4 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/xumirazita
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
var original = ['hello', 'there', 'i', 'am', 'Manish'] | |
var copy1 = original.slice(0); | |
var copy2 = [...original] | |
var deepCopy = [["firstArray", ["innerArray"]]] | |
var shallowCopy = deepCopy[0] | |
//shallowCopy[0] = "hello" | |
//console.log(shallowCopy[0]); | |
var allCopy = JSON.parse(JSON.stringify(deepCopy)) | |
allCopy[0].push("addOne") | |
let deepCopyMap = deepCopy.map(x => x); | |
//console.log(deepCopy); | |
//console.log(deepCopyMap); | |
const nested = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; | |
flat = nested.flat() | |
console.log(nested) | |
console.log(flat) | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var original = ['hello', 'there', 'i', 'am', 'Manish'] | |
var copy1 = original.slice(0); | |
var copy2 = [...original] | |
var deepCopy = [["firstArray", ["innerArray"]]] | |
var shallowCopy = deepCopy[0] | |
//shallowCopy[0] = "hello" | |
//console.log(shallowCopy[0]); | |
var allCopy = JSON.parse(JSON.stringify(deepCopy)) | |
allCopy[0].push("addOne") | |
let deepCopyMap = deepCopy.map(x => x); | |
//console.log(deepCopy); | |
//console.log(deepCopyMap); | |
const nested = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; | |
flat = nested.flat() | |
console.log(nested) | |
console.log(flat) | |
</script></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var original = ['hello', 'there', 'i', 'am', 'Manish'] | |
var copy1 = original.slice(0); | |
var copy2 = [...original] | |
var deepCopy = [["firstArray", ["innerArray"]]] | |
var shallowCopy = deepCopy[0] | |
//shallowCopy[0] = "hello" | |
//console.log(shallowCopy[0]); | |
var allCopy = JSON.parse(JSON.stringify(deepCopy)) | |
allCopy[0].push("addOne") | |
let deepCopyMap = deepCopy.map(x => x); | |
//console.log(deepCopy); | |
//console.log(deepCopyMap); | |
const nested = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; | |
flat = nested.flat() | |
console.log(nested) | |
console.log(flat) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment