Premium Only Content

`_.where` function on array using JavaScript Library underscore.js ( #shorts )
Hi Friends,
`_.where` function on array using JavaScript Library underscore.js
`_.where` is a utility function in Underscore.js library that allows you to filter a collection based on multiple key-value pairs. It returns an array of all objects from the collection that match the specified properties.
In below example, we have an array of user objects users. We use _.where to filter the collection and retrieve all objects that have the property city set to "London". The result, filteredUsers, is an array containing the user objects that match the specified key-value pair.
Note: _.where returns an array containing all objects from the collection that match the specified key-value pairs.
// syntax
_.where(list, properties)
// example
var users = [
{ name: "Alice", age: 25, city: "New York" },
{ name: "Bob", age: 30, city: "London" },
{ name: "Charlie", age: 20, city: "Paris" },
{ name: "David", age: 35, city: "London" }
];
var filteredUsers = _.where(users, { city: "London" });
console.log(filteredUsers);
// [{ name: "Bob", age: 30, city: "London" },
// { name: "David", age: 35, city: "London" }]
#javascript #under #score #underscore #underscorejs #findWhere #findwhere #find #where #underscorefindwhere #findwherefunction #unique #object #array #string #nodejs #javascriptinterview #method #js #jquery #function #shorts #viral #popular #latest #new #coders #development #code #dev #interview #php #trend #trending #answer #laravel #youtube #instagram #socialmedia #education #edit #how #india #knowledge #quiz #reels #short #subscribe #share #update #video #web #webdeveloper #website #webdesign #ytshorts #youtuber #princecheema_official @princecheema_official
-
LIVE
Major League Fishing
5 days agoLIVE! - Fishing Clash Team Series: Heritage Cup - Day 2
777 watching -
10:31
Dr. Eric Berg
2 hours ago13 Foods You Should Never Buy Organic
8.83K10 -
15:10
SB Mowing
1 month agoShe had TEARS OF JOY on her face - An update on Beth
8.34K31 -
LIVE
Lofi Girl
3 years agolofi hip hop radio 📚 - beats to relax/study to
203 watching -
LIVE
Nikko Ortiz
2 hours agoLIVE - Trying Rumble Studio!
203 watching -
9:30
Sugar Spun Run
5 hours agoBlack and White Cookies
31K1 -
2:45
SLS - Street League Skateboarding
4 days agoManny Santiago's 'THIS IS 40' Part
18.3K2 -
6:40
Homesteading Family
5 days agoNever Make Pie Crust From Scratch Again (Do THIS Instead)
14.2K4 -
44:20
Melissa K Norris
3 days ago $0.30 earnedThe Most Overlooked Way to Preserve Food for Months (No Freezer Needed) w/ Sam Knapp
10K1 -
23:00
Tony Jeffries
6 days agoThe Best & Worst Boxing Training Methods (Ranked by Olympic Boxer)
7.06K