Arrow function => No binding of this

Idan Mor (sidanmor)
sidanmor
Published in
1 min readJul 20, 2017

--

Until arrow functions, every new function defined its own this value (a new object in the case of a constructor, undefined in strict mode function calls, the base object if the function is called as an “object method”, etc.)

Alternatively, a bound function could be created so that a preassigned this value would be passed to the bound target function.

An arrow function does not create its own this, the this value of the enclosing execution context is used. Thus, in the following code, the this within the function has the same value as this in the enclosing scope (window object in this case):

References:

https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions

--

--

Full-Stack Team Leader, Senior Full-Stack Software Engineer and Javascript Ninja