var foo = { n: 1 }; (function (foo) { console.log(foo.n) foo.n = 3 var foo = { n: 2 } foo.n = 4 console.log(foo.n) })(foo) console.log(foo.n);