
array.find() – Returns the **first element** that satisfies the provided testing function or `undefined`.
๐ Syntax
element = array.find((element, index, array) => {
return /* condition */;
}, thisArg);
๐งช Example
const users=[{id:1},{id:2}];
console.log(users.find(u => u.id === 2)); // {id:2}
Comments
Post a Comment