0

I am pushing a structure to an array which looks like the following

arr.push( {age: 32, name: "Joe"} );
arr.push( {age: 93, name: "Mike"} );
arr.push( {age: 19, name: "Billy"} );

What I would like to do is just find out if "Mike" is in the array. Something like:

arr.includes({name: "Mike"})

I know this doesn't work but it shows what I'm looking for.

jiveturkey
  • 2,484
  • 1
  • 23
  • 41

1 Answers1

2

you can use find in following way to get the targeted node from array of objects

let result = array.find(t=>t.name=='Mike')

Jatin Parmar
  • 2,759
  • 5
  • 20
  • 31