How to find a value in an array of objects in Javascript?

Rashmi
Rashmi
1068 Points
19 Posts

I have following json array object and need to get one item on the basis of some filter:

var array = [
    { name:"string 1", value:"this", other: "that" },
    { name:"string 2", value:"this", other: "that" }
];

How to find an object value in an array of objects?

Views: 968
Total Answered: 1
Total Marked As Answer: 1
Posted On: 15-Nov-2021 06:30

Share:   fb twitter linkedin
Answers
edx
edx
506 Points
24 Posts
         

try something:

var sigleObject = array.find(x => x.name === 'string 1')

print(sigleObject.value);
Posted On: 16-Nov-2021 04:10
 Log In to Chat