Last active
August 29, 2015 14:15
-
-
Save pr00thmatic/fa02632d188bab6e4bcd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var dog = (function () { | |
// execution context: dog's module | |
var nombre = "dog"; | |
var setName = function (newName) { | |
nombre = newName; | |
}; | |
var speak = function () { | |
console.log('[' + nombre + ']: woof!'); | |
}; | |
return { | |
// execution context: dog (the actually returned dog) | |
setName : setName, | |
speak : speak | |
}; | |
})(); | |
dog.speak(); // [dog]: woof! | |
dog.setName('Shipo'); | |
dog.speak(); // [Shipo]: woof! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment