Skip to content

Instantly share code, notes, and snippets.

@vidhill
Created September 6, 2019 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vidhill/9c6337741028bdae387e4890a655a253 to your computer and use it in GitHub Desktop.
Save vidhill/9c6337741028bdae387e4890a655a253 to your computer and use it in GitHub Desktop.
const doFoo = (passedObj) => {
passedObj.foo = true;
passedObj.bar = false;
return {
cat: 'meow',
passedObj
};
}
const objectA = {};
const result = doFoo(objectA);
console.log(result.passedObj === objectA) // equals true
// and even worse!
console.log(objectA) // logs { "foo": true, "bar": false }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment