Search
 
SCRIPT & CODE EXAMPLE
 

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 }
Comment

PREVIOUS NEXT
Code Example
Javascript :: function countdown() 21 sec 
Javascript :: alert function in javascript 
Javascript :: sweetalert example 
Javascript :: Mongoose filter by multiple fields 
Javascript :: javascript things to remember 
Javascript :: jquery remove elemtns 
Javascript :: declaring constant in jsx 
Javascript :: javascript wrap object in array 
Javascript :: how to get every index of array in javascript 
Javascript :: subtrair datas javascript frontend 
Javascript :: how to get current date in express js 
Javascript :: svg in react native 
Javascript :: create express js project 
Javascript :: online javascript compiler 
Javascript :: react router history not defined 
Javascript :: nuxt auth keep user loggedin on refresh 
Javascript :: js filter array of objects by another object 
Javascript :: foreach method of array in javascript 
Javascript :: react js error boundary functional component 
Javascript :: angular img tag 
Javascript :: javascript array.contains 
Javascript :: how to use if condition in jquery validation 
Javascript :: js download file from webserver 
Javascript :: delete element from array js 
Javascript :: mongodb mongoose update convert string to object 
Javascript :: js empty map 
Javascript :: update data in json using javascript 
Javascript :: nodejs fs writefile base64url 
Javascript :: download datepicker js 
Javascript :: how to set value of tinymce in javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =