Fat arrow functions or arrow functions in Javascript
interview questions , Javascript / February 20, 2018

Arrow Functions primarly have two big advantages 1 They let us provide a shorter way to define functions 2  Arrow functions does not have their own  this, arguments(JavaScript functions have a built-in object called the arguments object), super, or new.target. These functions cannot be used as constructors.Arrow functions does not have their own this and it will have this value from their enclosing context .We can use this from the surrounding scope inside an arrow function such that we need not use bind() to bind this to a callback function.This more shorter yet more efficient way of writing a function was introduced in ES6. 1 They let us provide a shorter way to define functions Arrow functions provide us with a shorter way to defined function.For example see the following function which is written using the normal syntax

  The console.log gives output 6 . Now check the same function using arrow syntax

Now we can see a function with  a few parameters

Using arrow syntax

  2 Arrow functions – this,callbacks and bind() To understand more on this keyword read the following link https://truetocode.com/understanding-this-in-javascript/844/. See the following example.this is not available inside the callback function

To make this available inside the callback function…

Share this page in social media platforms