鉴于以下coffeescript代码:
class Animal constructor: (@name) -> speak: (things) -> "My name is #{@name} and I like #{things}"
这是生成的:
var Animal = (function() { function Animal(name) { this.name = name; } Animal.prototype.speak = function(things) { return "My name is " + this.name + " and I like " + things; }; return Animal; })();
但为什么这个惯用代码不会产生呢?
var Animal = function Animal(name) { this.name = name; }; Animal.prototype.speak = function(things) { return "My name is " + this.name + " and I like " + things; };
我知道coffeescript在匿名函数中包含很多东西来控制范围泄漏,但是这里可能会泄漏什么?