Answers for "using arrow functions in javascript class"

0

why can't you use arrow function with this in javascript for declaring methods

'use strict';

var obj = { // does not create a new scope
  i: 10,
  b: () => console.log(this.i, this),
  c: function() {
    console.log(this.i, this);
  }
}

obj.b(); // prints undefined, Window {...} (or the global object)
obj.c()
Posted by: Guest on July-16-2021

Code answers related to "using arrow functions in javascript class"

Code answers related to "Javascript"

Browse Popular Code Answers by Language