javascript / beginner
Snippet
Locating Data with Array.find()
The find() method returns the first element in the provided array that satisfies the provided testing function.
snippet.js
1
const user = users.find(u => u.id === 1);
nextjs
Breakdown
1
users.find(...)
Searches through the array for a specific item.
2
u.id === 1
The condition: return the first item where the ID matches 1.