Skip to content

Instantly share code, notes, and snippets.

@snippe
Created December 31, 2014 04:19
Show Gist options
  • Save snippe/f125b079c095e7628cfd to your computer and use it in GitHub Desktop.
Save snippe/f125b079c095e7628cfd to your computer and use it in GitHub Desktop.
function changeValue(val) {
val = val + " changed";
console.log(val); //A changed
}
var val = "A";
changeValue(val);
console.log(val); //A
//----------------------------
function changeObj(obj) {
obj.oldProp = 'older';
obj.newProp = 'new Prop';
}
var obj = { oldProp: "old" };
changeObj(obj);
console.log(obj.hasOwnProperty('newProp')); //true
console.log(obj.oldProp); //older
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment