Created
November 10, 2018 21:01
-
-
Save fay-jai/5ccaaae475d7c29a44f2dc8132d52c36 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
function doSomethingWith(array) { | |
// do something with array here | |
} | |
let array = [1, 2, 3]; // In languages like JavaScript, arrays are mutable data structures where you can add and remove values without changing the reference to the underlying object. | |
doSomethingWith(array); // When doSomethingWith is passed the array as an argument, we pass it by reference. The implication here is that whatever happens inside of the function can mutate the underlying array. | |
console.log(array); // At this point, you don't actually know what to expect when you log the array - does it still have [1, 2, 3] or does it have other values? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment