Skip to content

Instantly share code, notes, and snippets.

@daronwolff
Created May 23, 2016 21:58
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 daronwolff/4d87ce60659283137c24e85869fdf292 to your computer and use it in GitHub Desktop.
Save daronwolff/4d87ce60659283137c24e85869fdf292 to your computer and use it in GitHub Desktop.
Prototype examples
function Triangle() {
this.a;
this.b;
this.c;
this.setSides = function(a, b, c) {
this.a = a;
this.b = b;
this.c = c;
};
this.toString = function() {
console.log(" A " + this.a + " B " + this.b + " C " + this.c);
};
}
var t = new Triangle();
t.setSides(20, 30, 44);
//t.toString();
function Equilateral() {
}
Equilateral.prototype = new Triangle();
Equilateral.prototype.setSides = function(a) {
this.a = a;
this.b = a;
this.c = a;
}
var eq = new Equilateral();
eq.setSides(50);
eq.toString();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment