Skip to content

Instantly share code, notes, and snippets.

@ww24
Created June 6, 2014 09:06
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 ww24/f030530df47990ab6bb3 to your computer and use it in GitHub Desktop.
Save ww24/f030530df47990ab6bb3 to your computer and use it in GitHub Desktop.
JavaScript のオブジェクト指向
function F(message) {
this.message = message;
}
F.prototype.print = function () {
console.log(this.message);
};
// F を継承した G
function G(message, name) {
F.call(this, message);
this.name = name;
}
G.prototype.echo = function () {
console.log(this.message + ", " + this.name);
};
var f = new F("Hello");
f.print();
var g = new G("Hello", "World");
g.echo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment