Created
April 2, 2019 21:18
-
-
Save ositowang/792d0d74a7f6f2bd2399e97bb4308af3 to your computer and use it in GitHub Desktop.
pragmatic way of using call
This file contains 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 domNodeArrays = Array.prototype.slice.call(domNodes); | |
// now domNodeArrays has the unshift methods | |
domNodeArrays.unshift("h1"); | |
let test = [1,2,3,4] | |
// we make a shallow copy of the orignal array, now we are isolated | |
let shallowCopy = [].slice.call(test) | |
test[1] = 4 | |
console.log(shallowCopy[1]) | |
console.log(test[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment