Skip to content

Instantly share code, notes, and snippets.

@kasei-san
Created July 28, 2015 22:46
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 kasei-san/f189d6701b4695444d66 to your computer and use it in GitHub Desktop.
Save kasei-san/f189d6701b4695444d66 to your computer and use it in GitHub Desktop.
関数・メソッド・コンストラクタ
function test(){ // 関数
console.log("test");
}
function Animal(type, voice){ // コンストラクタ
this.type = type;
this.bark = function(){ // メソッド
console.log(voice);
};
}
test(); // 関数実行
var dog = new Animal('dog', 'bow'); // コンストラクタ実行
dog.bark(); // メソッド実行
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment