Skip to content

Instantly share code, notes, and snippets.

@Ptico
Created February 16, 2012 14:18
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 Ptico/1845153 to your computer and use it in GitHub Desktop.
Save Ptico/1845153 to your computer and use it in GitHub Desktop.
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