Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

fat arrow function

// Traditional Anonymous Function
(function (a) {
  return a + 100;
});

// Arrow Function Break Down

// 1. Remove the word "function" and place arrow between the argument and opening body bracket
(a) => {
  return a + 100;
};

// 2. Remove the body braces and word "return" — the return is implied.
(a) => a + 100;

// 3. Remove the argument parentheses
a => a + 100;

// Arrow Function
(a, b) => {
  const chuck = 42;
  return a + b + chuck;
};


//Function use with Map function
const materials = [
  'Hydrogen',
  'Helium',
  'Lithium',
  'Beryllium'
];

console.log(materials.map(material => material.length));
// expected output: Array [8, 6, 7, 9]
Comment

PREVIOUS NEXT
Code Example
Javascript :: remove duplicate value from string 
Javascript :: Handle click outside a component in react with hooks 
Javascript :: discord bot javascript 
Javascript :: How to send form data from react to express 
Javascript :: remove object from array by name javascript 
Javascript :: frequency of characters in a string in javascript 
Javascript :: how to remove an class in javascript 
Javascript :: how to validate phone number regex javascript 
Javascript :: milliseconds to date javascript 
Javascript :: javascript url pas array 
Javascript :: Auto open browser when run dev nextjs 
Javascript :: primitive data types in javascript 
Javascript :: js remove last character 
Javascript :: jquery preload images 
Javascript :: read url param data in javascript 
Javascript :: cookie in javascript 
Javascript :: express command not found mac 
Javascript :: queryselectorall in javascript to get data attribute value 
Javascript :: js check if a variable is an array 
Javascript :: javascript combine two index elements 
Javascript :: dropzone csrf codeigniter 
Javascript :: javascript array any 
Javascript :: javascript array group by id 
Javascript :: to do list local storage javascript 
Javascript :: vue 3 route params 
Javascript :: Limit text to specified number of words using Javascript 
Javascript :: javascript textarea autosize 
Javascript :: js settimeout wait element 
Javascript :: javascript add event listenner for multiple events 
Javascript :: js merge 2 form data 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =