Theme
Primary Color
Lesson 4

Arrow Function - Syntax And Examples

محتوى الدرس

/*
  Arrow Function
*/

// Regular Function With No Parameters
let regularTestOne = function () {
  return 2;
}

// Arrow Function With No Parameters
let arrowTestOne = () => 2;
let arrowTestTwo = _ => 2;

// Regular Function With One Parameter
let regularTestTwo = function (param) {
  return param * 2;
}

// Arrow Function With One Parameter
let arrowTestThree = (param) => param * 2;
let arrowTestFour = param => param * 2;

console.log(arrowTestFour(22))

// Regular Function With Multiple Parameters
let regularTestThree = function (param1, param2) {
  return param1 * param2;
}

console.log(regularTestThree(10, 30))

// Arrow Function With Multiple Parameters
let arrowTestFive = (param1, param2) => param1 * param2;

console.log(arrowTestFive(10, 30))