When should you NOT use arrow functions in ES6? Name three or more cases.

Technology CommunityCategory: JavaScriptWhen should you NOT use arrow functions in ES6? Name three or more cases.
VietMX Staff asked 3 years ago

Arrow functions should NOT be used:

  • When we want function hoisting – as arrow functions are anonymous.
  • When we want to use this/arguments in a function – as arrow functions do not have this/arguments of their own, they depend upon their outer context.
  • When we want to use named function – as arrow functions are anonymous.
  • When we want to use function as a constructor – as arrow functions do not have their own this.
  • When we want to add function as a property in object literal and use object in it – as we can not access this (which should be object itself).