Skip to content

Instantly share code, notes, and snippets.

@jesgundy
Created November 27, 2012 17:48
Show Gist options
  • Save jesgundy/4155834 to your computer and use it in GitHub Desktop.
Save jesgundy/4155834 to your computer and use it in GitHub Desktop.
Prototypal inheritance example
// Prototype Example
var Example = function(a, b) {
this.product = this.mult(a, b);
this.power = this.pow(a, b);
};
Example.prototype = {
mult: function(a, b) {
return a * b;
},
pow: function(num, pow) {
var n = num;
while (pow -= 1) n = this.mult(n, num);
return n;
}
};
var demo = new Example(2, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment