var cars = [ {make: "Honda", model: "Civic", year: 2018}, {make: "Toyota", model: "Corolla", year: 2019}, {make: "Ford", model: "Focus", year: 2020} ]; var honda = _.findWhere(cars, {make: "Honda"}); console.log(honda); // output: {make: "Honda", model: "Civic", year: 2018}
var fruits = [ {name: "apple", color: "red", price: 0.99}, {name: "banana", color: "yellow", price: 0.25}, {name: "grape", color: "purple", price: 1.50} ]; var cheapFruit = _.findWhere(fruits, {color: "yellow", price: 0.25}); console.log(cheapFruit); // output: {name: "banana", color: "yellow", price: 0.25}In these examples, we are using the `_` symbol to reference the Underscore.js library in our code. Therefore, `_.findWhere` is part of the Underscore.js library.