Created
July 28, 2015 22:46
-
-
Save kasei-san/f189d6701b4695444d66 to your computer and use it in GitHub Desktop.
関数・メソッド・コンストラクタ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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