Created
October 8, 2021 21:22
-
-
Save jt0dd/4eb4354129ec9a30a49f01b7b64473ef 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 replace(ref) { | |
ref = {}; // this code does _not_ affect the object passed | |
} | |
function update(ref) { | |
ref.key = 'newvalue'; // this code _does_ affect the _contents_ of the object | |
} | |
var a = { key: 'value' }; | |
replace(a); // a still has its original value - it's unmodfied | |
update(a); // the _contents_ of 'a' are changed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment