Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js find in array

const inventory = [
  {id: 23, quantity: 2},
  {id: '24', quantity: 0},
  {id: 25, quantity: 5}
];
// Check type and value using ===
const result = inventory.find( ({ id }) => id === 23 );
// Check only value using ==
const result = inventory.find( ({ id }) => id == 24 );
 
PREVIOUS NEXT
Tagged: #js #find #array
ADD COMMENT
Topic
Name
9+4 =