Created
February 16, 2012 14:18
-
-
Save Ptico/1845153 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
var Baby = (function() { | |
function Baby(name) { // Constructor | |
this.name = name; | |
} | |
Baby.prototype = { // Public | |
introduce: function() { | |
alert("Hello! My name is " + name); | |
}, | |
play: function() { | |
run(); | |
jump(); | |
scream(); | |
} | |
}; | |
// Private | |
function run() { | |
alert("Run baby, run!"); | |
} | |
function jump() { | |
alert("Beowm, beowm, beowm!"); | |
} | |
function scream() { | |
alert("A-A-A-A-A-A!"); | |
} | |
return Baby; | |
})(); | |
var alice = new Baby("Alice"); | |
alice.introduce(); | |
alice.play(); | |
alice.jump(); // Will fail |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment