Last active
August 29, 2015 14:26
-
-
Save zaki-yama/c780926709092bd5f2d7 to your computer and use it in GitHub Desktop.
ES6とTypeScript、CoffeeScriptの比較
This file contains 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
### CoffeeScript ### | |
class Person | |
# コンストラクタ & プロパティ | |
constructor: (@name) -> | |
# インスタンスメソッド | |
greet: () -> | |
console.log 'Hello, I\'m ' + this.name | |
# スタティックメソッド | |
@create: (name) -> | |
return new Person(name) | |
window.Person = Person |
This file contains 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
/* | |
* TypeScript | |
*/ | |
// クラス定義 | |
class Person { | |
// プロパティ | |
private name: string; | |
// コンストラクタ | |
constructor(name: string) { | |
this.name = name; | |
} | |
// インスタンスメソッド | |
greet(): void { | |
console.log('Hello, I\'m ' + this.name); | |
} | |
// スタティックメソッド | |
static create(name: string): Person { | |
return new Person(name); | |
} | |
} |
This file contains 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
/* | |
* EcmaScript 6 | |
*/ | |
// クラス定義 | |
class Person { | |
// コンストラクタ | |
constructor(name) { | |
// プロパティ | |
this.name = name; | |
} | |
// インスタンスメソッド | |
greet() { | |
console.log('Hello, I\'m ' + this.name); | |
} | |
// スタティックメソッド | |
static create(name) { | |
return new Person(name); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment