Answers for "arrow function use in class in js"

0

arrow function javascript rules

const sayHi = ()=>console.log('Hi');
Posted by: Guest on January-01-2022
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 "Javascript"

Browse Popular Code Answers by Language