title: Using ES6 Arrow Functions in Node 0.11 w/ Foo.prototype
body: <p>I'm getting what I see as unexpected behavior in using arrow functions inside a prototype extension.</p>
  
  <pre><code>function ES6Example(){}
  ES6Example.prototype.foo = function(bar){
    return ((baz) =&gt; {
      console.log(this)
      this.bar = baz
    })(bar)
  }
  
  var es6Example = new ES6Example
  es6Example.foo('qux')
  
  console.info(es6Example.bar)
  </code></pre>
  
  <p>The above code results in the global context being printed out, as well as <code>es6Example.bar</code> being undefined. This is the old behavior. Based on the docs I've seen in MDN I expected this to be bound to the instance. I am running the above code using Node v0.11.15 using the harmony flag. Note that the following does work:</p>
  
  <pre><code>function ES6Example(){
      this.foo = baz =&gt; {
        this.bar = baz
      }
  }
  </code></pre>