使用胖箭头(将函数绑定到 this 的当前值)和将 @ 的值放入变量有什么区别?
胖箭头
Account = (customer, cart) ->
@customer = customer
@cart = cart
$('.shopping_cart').bind 'click', (event) =>
@customer.purchase @cart
和
Account = (customer, cart) ->
@customer = customer
@cart = cart
self = @
$('.shopping_cart').bind 'click', (event) ->
self.customer.purchase self.cart
@建议使用粗箭头避免弄乱周围的范围。如何?