News for hackers. Stuff that matters.
Re:ES6 in Depth: Classes by raziel2p on Thursday July 23, 2015 @02:37PM (#9937638)
Working with classes in ES6 is such a relief. My only complaint is that if you save a method as a variable or pass it to another function, it'll just be a function with its own scope (`this` won't reference the class instance, but instead the method function).

Easily "fixed" if you remember to put `.bind(this)` everywhere, though.

Re:ES6 in Depth: Classes by hokkos on Thursday July 23, 2015 @02:47PM (#9937701)
Or use :

  myMethod = (arg) => {return this.value + arg;}
With es7.classProperties in babel. https://babeljs.io/docs/usage/experimental/
Re:ES6 in Depth: Classes by karcass on Thursday July 23, 2015 @03:35PM (#9937958)
Or more tersely:

  myMethod = arg => this.value + arg;
Re:ES6 in Depth: Classes by Cshelton on Thursday July 23, 2015 @02:50PM (#9937719)
or depending on what you are doing in that method, use a get myProperty() {//do stuff and return prop}
Re:ES6 in Depth: Classes by savanaly on Thursday July 23, 2015 @02:47PM (#9937702)
Sample code from just this afternoon:

      const typeMap = {
        'i-text': this.processText.bind(this),
        'image': this.processImage.bind(this),
        'rect': this.processRectangle.bind(this)
      };
Really annoying if you ask me, though I understand why it had to be this way.