I have an huge array of object and need to find the name of object by key, how can I do that with the optimized way.
const key = 2;
const arr = [ {id: 1, text: '1111'}, {id: 2, text: '2222'}, {id: 3, text: '333'},]
I need to return only the text '2222' The original array have an 154 object thats why I need the most optimized way.
arr.forEach((obj) => {
Object.keys(obj).forEach((key) => {
console.log("key : " + key + " - value : " + obj[key]);
});
});