Created
June 15, 2014 05:30
-
-
Save gam0022/39a6ee599c213b269489 to your computer and use it in GitHub Desktop.
JavaScriptとCoffeeScriptのメモ ref: http://qiita.com/gam0022/items/61022bb50ffd7cf28400
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
class Hoge | |
someInstanceProp: [1,2,3] # インスタンス変数 | |
someInstanceMethod: -> # インスタンスメソッド | |
@callAnotherInstanceMethod() # インスタンスメソッドを呼ぶ | |
alert @someInstanceProp # ==> "hoge" | |
@someClassProp: "hogehoge" # クラス変数 | |
@someClassMethod: -> # クラスメソッド | |
@callAnotherClassMethod() # 同一クラスのクラスメソッドを呼ぶ | |
alert @someClassProp # ==> "hogehoge" | |
h1 = new Hoge() | |
alert h1.someInstanceProp # => [1,2,3] | |
h1.someInstanceProp.reverse() | |
alert h1.someInstanceProp # => [3,2,1] | |
h2 = new Hoge() | |
alert h2.someInstanceProp # => [3,2,1] !他のクラスでの変更の影響を受けている |
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
class Hoge | |
constructor: () -> | |
@someInstanceProp = [1,2,3] # インスタンス変数 | |
someInstanceMethod: -> # インスタンスメソッド | |
@callAnotherInstanceMethod() # インスタンスメソッドを呼ぶ | |
alert @someInstanceProp # ==> "hoge" | |
@someClassProp: "hogehoge" # クラス変数 | |
@someClassMethod: -> # クラスメソッド | |
@callAnotherClassMethod() # 同一クラスのクラスメソッドを呼ぶ | |
alert @someClassProp # ==> "hogehoge" | |
h1 = new Hoge() | |
alert h1.someInstanceProp # => [1,2,3] | |
h1.someInstanceProp.reverse() | |
alert h1.someInstanceProp # => [3,2,1] | |
h2 = new Hoge() | |
alert h2.someInstanceProp # => [1,2,3] |
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
class Hoge | |
someInstanceProp: "hoge" # インスタンス変数 | |
someInstanceMethod: -> # インスタンスメソッド | |
@callAnotherInstanceMethod() # インスタンスメソッドを呼ぶ | |
alert @someInstanceProp # ==> "hoge" | |
@someClassProp: "hogehoge" # クラス変数 | |
@someClassMethod: -> # クラスメソッド | |
@callAnotherClassMethod() # 同一クラスのクラスメソッドを呼ぶ | |
alert @someClassProp # ==> "hogehoge" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment