Skip to content

Instantly share code, notes, and snippets.

@Macagare
Created November 12, 2012 08:32
Show Gist options
  • Save Macagare/4058163 to your computer and use it in GitHub Desktop.
Save Macagare/4058163 to your computer and use it in GitHub Desktop.
Javascript: Class (using a function)
function Apple (type) {
this.type = type;
this.color = "red";
this.getInfo = function() {
return this.color + ' ' + this.type + ' apple';
};
}
// Or, this other way:
function Apple (type) {
this.type = type;
this.color = "red";
}
Apple.prototype.getInfo = function() {
return this.color + ' ' + this.type + ' apple';
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment