February 2018
Intermediate to advanced
298 pages
8h 22m
English
In arrow functions, the value of the this keyword is the same as the value of the this keyword of the enclosing scope (the global or function scope, whichever the arrow function is defined inside). That means, instead of referring to the context object (that is, the object inside which the function is a property), which is the value of this in traditional functions, this instead refers to global or function scope, in which the function is called. Consider this example to understand the difference between the traditional functions and the arrow functions, this value:
var car = { name: 'Bugatti', fuel: 0, // site A addFuel: function() { // site B setInterval(function() { // site C this.fuel++; console.log("The ...Read now
Unlock full access