Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Using arrow function and destructuring

const inventory = [
  {name: 'apples', quantity: 2},
  {name: 'bananas', quantity: 0},
  {name: 'cherries', quantity: 5}
];

const result = inventory.find( ({ name }) => name === 'cherries' );

console.log(result) // { name: 'cherries', quantity: 5 }
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #Using #arrow #function #destructuring
ADD COMMENT
Topic
Name
3+4 =