es6 array function map function with arrow code example

Example 1: array map arrow function

materials.map((str) => {
  const {length} = str;
  return length;
});

Example 2: pass a variable by reference to arrow function

// Parenthesize the body of a function to return an object literal expression:
params => ({foo: bar})

// Rest parameters and default parameters are supported
(param1, param2, ...rest) => { statements }
(param1 = defaultValue1, param2,, paramN = defaultValueN) => { 
statements }

// Destructuring within the parameter list is also supported
var f = ([a, b] = [1, 2], {x: c} = {x: a + b}) => a + b + c;
f(); // 6