Created
March 16, 2017 20:00
-
-
Save awilson28/5556a2511878883c68296c84b8a7f502 to your computer and use it in GitHub Desktop.
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 a = [1, 2, 3]; | |
function doSomething(b){ // the parameter `b` that corresponds to the argument `a` is a copy of a reference to the array a | |
b = [2]; //if we change b via reassignment inside a function or outside of the function, that reassignment does not affect a | |
console.log(b) // [2] | |
} | |
doSomething(a); | |
console.log(a) // [1, 2, 3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment