【发布时间】:2012-12-31 22:47:09
【问题描述】:
在 JS 中,我可以这样做:
for(i in MyClass.prototype) {
console.log(i);
}
它会显示方法名称。没关系。
现在,如果我用 coffeescript 做这个:
for i in MyClass.prototype
console.log i
它将被编译为:
var i, _i, _len, _ref;
_ref = MyClass.prototype;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
i = _ref[_i];
console.log(i);
}
但是原型没有length 属性,所以它坏了。
我怎样才能用coffeescript制作它?
【问题讨论】:
-
感谢您的链接我明白了!
标签: coffeescript