Skip to content

Instantly share code, notes, and snippets.

@phiggins42
Created March 25, 2010 21:34
Show Gist options
  • Save phiggins42/344160 to your computer and use it in GitHub Desktop.
Save phiggins42/344160 to your computer and use it in GitHub Desktop.
(function(){
// normal ass object:
var obj = {
me:37
};
function mangler(arg, num){
// `arg` is literally `obj`
arg.me = num;
// `other`, by reference, is also `obj`
var other = arg;
other.me = num * 2;
}
console.log(obj.me); // 37
mangler(obj, 10);
console.log(obj.me); // 20
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment