CoffeeScriptのthis束縛、即時関数

CoffeeScript

# thisをbindする
func = (x, y) =>
  x + y + @z

# thisをbindしない
func = () ->
  x + y + @z

# 即時関数、引数あり
do (x, y) ->
  x + y + @z

# 即時関数、引数なし
do ->
  x + y + @z

JSへの変換結果

var func;

func = (function(_this) {
  return function(x, y) {
    return x + y + _this.z;
  };
})(this);

func = function() {
  return x + y + this.z;
};

(function(x, y) {
  return x + y + this.z;
})(x, y);

(function() {
  return x + y + this.z;
})();