[πŸ˜ƒ, πŸ€, πŸ…, 🐡].find(function(item) {
    return item === πŸ€;
}); // πŸ‘‰ πŸ€
// Create an array
const colors = ["red", "green", "blue"];

// Find the first element that satisfies the condition
const green = colors.find(function(color) {
    return color === "green"; // check if the element is "green"
});

// Output the result
console.log(green); // Output: "green"
arr.find(callbackFn[, thisArg])
// Arrow function
find((element) => { /* … */ })
find((element[, index]) => { /* … */ })
find((element[, index[, array]]) => { /* … */ })

// Callback function reference
find(callbackFn)
find(callbackFn[, thisArg])

// Inline callback function
find(function (element) { /* … */ })
find(function (element[, index]) { /* … */ })
find(function (element[, index[, array]]) { /* … */ })
find(function (element[, index[, array]]) { /* … */ }[, thisArg])
callbackFn(element[, index[, array]])
/**
 * Callback function
 *
 * @param {*} element Each element in the array
 * @param {number} index Optional. The index of the element
 * @param {Array} array Optional. The original array
 * @return {boolean} Returns true if the condition is met, otherwise false
 *
 * The callback function can be a named function (user-defined) or an anonymous function.
 * All callback functions can also be written as arrow functions.
 */

/* Using a named function as the callback */
function callbackFn(element[, index[, array]]) { // Named function definition
    // Define the condition using a return statement
}

arr.find(callbackFn); // Pass the defined named function directly as the argument

/* Using an anonymous function as the callback */
arr.find(function(element[, index[, array]]) {
    // Define the condition using a return statement
});
const numbers = [1, 2, 3, 4, 5];
const target = 3;
const found = numbers.find(element => element === target);

console.log(found); // Output: 3
const people = [
    {name: "Alice", age: 30},
    {name: "Bob", age: 25},
    {name: "Charlie", age: 35}
];

const targetName = "Bob";
const person = people.find(obj => obj.name === targetName);

console.log(person); // Output: {name: "Bob", age: 25}
const products = [
    {name: "Laptop", price: 1000},
    {name: "Phone", price: 500},
    {name: "Tablet", price: 300}
];

const customCondition = product => product.price < 600;
const affordableProduct = products.find(customCondition);

console.log(affordableProduct); // Output: {name: "Phone", price: 500}