WebMasterCampus
WEB DEVELOPER Resources

Javascript ES6 Arrow Functions

Learn Javascript ES6 Arrow Functions


Arrow Functions

Arrow functions allows a short syntax for writing function expressions. You don’t need the function keyword the return keyword and the curly brackets.

Arrow Functions Example


//ES5 Syntax
var x = function (x,y) { return x*y; }
console.log(x(4,3));

//ES6 Syntax
const a = (b,c) => b * c;
console.log ( a(4, 3));

//ES6 Syntax with Rest Parameters
const sum = (...args) => {
  let result =0;
  
  for(let value of args){
    result += value
  }
  console.log(result)
}
sum(4,5,5,9,10)
Created with love and passion.