arrow function

PHOTO EMBED

Mon Jun 19 2023 15:36:04 GMT+0000 (Coordinated Universal Time)

Saved by @sarfraz_sheth #react.js

// option 1
const newVariable = (input1,input2) => {
  return input1 * input2;
}

// option 2
const newVariable = input1=> input1 * 2;

// example
var number = [1,2,4,50,62,45]
const newNumbers = number.map(input => input*2)
console.log(newNumbers)
content_copyCOPY

arrow function is to short the syntax to declare a function. importante para quitar el argumento return, la funcion debe ser de una sola expresion (solo una exprecion que se pueda expresar en una sola linea)