how to do `var self = this` inside es6 class?
How can we do like var self = this; as we used to do in ES5? You can do it exactly like you did in ES5 – ES6 is completely backward-compatible after all: class Point { constructor(x) { this.x = x; var self = this; this.toString = function() { return self.x; }; } } However, … Read more