Skip to content

Instantly share code, notes, and snippets.

@ositowang
Created April 2, 2019 21:18
Show Gist options
  • Save ositowang/792d0d74a7f6f2bd2399e97bb4308af3 to your computer and use it in GitHub Desktop.
Save ositowang/792d0d74a7f6f2bd2399e97bb4308af3 to your computer and use it in GitHub Desktop.
pragmatic way of using call
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