3

If we print the output of arguments variable inside a normal function:

var func = function() { console.log(arguments); }
func();

The result is an object which contains information about the context (parameter values, scope , functionLocation...)

But if we reproduce the same function with fat arrow, we will never get argument declared:

var func = () => { console.log(arguments); }
func();

// arguments is not defined

Can anyone explain how can we get the context data from arrow functions?

Cristian Batista
  • 283
  • 3
  • 17

1 Answers1

5

According to MDN

An arrow function expression has a shorter syntax than a function expression and does not have its own this, arguments, super, or new.target. These function expressions are best suited for non-method functions, and they cannot be used as constructors.