How can JS find an object with a specific key value in the Array with an object and assign values to other keys of that object

clipboard.png
as shown in the figure, I want to find the desired object with a specific id and be able to assign values to its contents.

it is known that you can use underscore_.findewhere

but want to know how everyone does it? How to write 0 0

in js native database
Mar.02,2021

function findWhere(list, properties) {
  const propertiesArray = Object.entries(properties)
  return list.find(item => {
    return propertiesArray.every(pair => {
      const key = pair[0]
      const value = pair[1]
      return item[key] && item[key] === value
    })
  })
}

const result = findWhere(shoppinglists, {id: 'clothes', title: 'Clothes'}) // result

tell me about the defect.

  1. will only return one object that satisfies the condition. If there is more than one object that meets the condition, you can overwrite it with the forEach method.
  2. if the value is a reference type, it cannot be determined and additional logic is required.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c220a3-32d3c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c220a3-32d3c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?