Skip to main content


Showing posts with the label function

Making Arrow in Javascript - ES 6

Arrow function aka fat arrrow was intorduced in ES6 as a new syntax for writing Javascript function.This is the most popular and highly used ES6 feature. Source Ponyfoo What is Arrow function? Arrow functions provide a different way of creating functions in JavaScript. Besides a shorter syntax, they offer advantages when it comes to keeping the scope of the this keyword. What I meant by this line is, unlike other functions, the value of this inside arrow functions is not dependent on how they are invoked or how they are defined.It depends only on its enclosing context. // ES5 - function declaration function callMe(name){              console.log(name);  } which you could also write as:  // ES5 - function expression const callMe = function(name) {         console.log(name); } becomes:  // ES6 const callMe = (name) => {              console.log(name);  } Important Uses: When having no arguments , you have to use empty parentheses in the function de