React & Autobinding
André Neves
3478

I disagree with the sentence: “ In the class-based approach the methods are simply JavaScript functions, and therefore are scoped themselves.”

The value of ‘this’ inside the functions of the following class is the context of the class, and not the scope of the function.

class Test  {
constructor() {
console.log(this);
this.i = 10;
}

bla(){
console.log(this);
}
}

let test = new Test();
test.bla(); // prints Test { i: 10 }
console.log(this);
Like what you read? Give Matan Bar Lev a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.