-
Understanding the Arrow function ( in javascript )
Why was the arrow function created ? As you may know that the arrow function was added to ES6. Why was this added though ? To solve two things. 1. Shorter function declarations 2. to solve the “this” problem 1. Shorter function is self evident: Lets take simple array manipulation. The map() method creates a new array with the results of calling a provided function on every element in the calling array Example A: Let us find the sqaure root of a given list of numbers var listofNumbers = [4,9,25]; console.log(listofNumbers.map(Math.sqrt)); //[2,3,5] In fact to lessen any possible confusion for […]