Created
August 27, 2019 14:35
-
-
Save jyotiarora2610/c62031496810037006c87068f795eff2 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
// Wrong way, bcoz variables are exposed. | |
// var foo = { | |
// o: {bar: 'fghj'}, | |
// test() { | |
// console.log('hello'); | |
// } | |
// } | |
// foo.test(); | |
// console.log(foo.o); | |
var foo = (function() { | |
var o = {foo: 'bar'}; | |
return { | |
bar: function() { | |
console.log(o.foo); | |
} | |
} | |
})(); | |
foo.bar(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment