Forgotten array built-in object - "Array.find ()

Requirements: An array that contains many objects, the object has a lot of attributes. You are given a value and that this value is again an array of objects exist, how to find the object?

  First thought was for loop through, but this is very troublesome, js provides us with a find () method, can be very easy to find this object

<Script> 
  var ARR = [{name: "Wang Qi", age: 18}, { name: " Li", Age: 20 is}] 
  the console.log (arr.find (Item => item.name, for === ' Wang Qi ')) 
 // {name: "Wang Qi", Age: 18 is} 
</ Script>

  

Guess you like

Origin www.cnblogs.com/wangqi2019/p/11717732.html