2012-03-01 5 views

答えて

25

あなたはクラスで取得するにはJavaScript constructor propertyを使用することができますし、そこに、あなたのfeetあります:私はconstructorための特別のCoffeeScriptの交換を知らないhttp://jsfiddle.net/ambiguous/ZfsqP/

class Cow 
    @feet: 4 
    constructor: (@name) -> 

class HexaCow extends Cow 
    @feet: 6 

bes = new Cow('Bessie') 
pan = new HexaCow('Pancakes') 

alert(bes.constructor.feet) # 4 
alert(pan.constructor.feet) # 6 
​ 

デモ。

関連する問題