let data = [{ a: 1, b: 2}, { a: 11, b: 12}, { a: 31, b: 23}, { a: 51, b: 24}]
How can you retrieve the object where a = 11
?
For simple arrays, one could use x.indexOf('1');
. So a potential solution could be:
let result = data.find(obj => obj.a === 11);
Of course, the goal is to obtain the entire JSON object that matches the specified value.