Premium Only Content

`_.get` function on object using JavaScript Library underscore.js ( #shorts )
Hi Friends,
`_.get` function on object using JavaScript Library underscore.js
`_.get` is a utility function in Underscore.js library is commonly used to retrieve the value of a nested property within an object, even if some intermediate properties do not exist without facing errors due to missing or undefined intermediate properties.
In below example, we have an object person with nested properties representing a person's details. We use _.get to retrieve the value of the city property within the address object. The result is "New York".
Note: _.get helps you handle situations where intermediate properties may be missing or undefined, preventing errors and allowing you to provide fallback values if needed.
// syntax
_.get(object, path, [defaultValue])
// example
var person = { name: "Annie", address: {
city: "New York",
street: { number: 123, name: "Main Street" }
}
};
var cityName = _.get(person, "address.city");
console.log(cityName);
// "New York"
#javascript #under #score #underscore #underscorejs #get #underscoreget #getfunction #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
Lofi Girl
2 years agoSynthwave Radio 🌌 - beats to chill/game to
324 watching -
20:14
GritsGG
11 hours agoHackers vs Win Squad! Let's Get it Done!
23 -
59:26
Omar Elattar
9 months agoFrom HEROIN To CEO: How I Overcame Addiction & Built A $120k/Month Business
179 -
26:18
Stephen Gardner
8 hours ago🔥YES! Trump makes TWO HUGE moves on Epstein!!
12K44 -
1:58:25
Badlands Media
12 hours agoDevolution Power Hour Ep. 373: Narrative Whiplash, Border Theater, and the Trump Time Bomb
73.4K36 -
1:01:56
Man in America
13 hours agoVICTORY! DOJ Drops All Charges Against Doctor Who Defied COVID Tyranny w/ Dr. Kirk Moore
42.9K33 -
7:30:55
RalliedLIVE
10 hours ago $16.07 earnedHIGH OCTANE WARZONE SOLOS ALL DAY
78K3 -
5:03:19
Spartan
5 hours agoSpartan - Pro Halo Player for OMiT | Ranked
19.4K1 -
1:57:36
DLDAfterDark
4 hours ago $3.68 earnedGuns Aren't Political - The Gun Owners Leadership Summit AKA G.O.A.L.S in Aug!
20.7K1 -
1:57:36
BlackDiamondGunsandGear
6 hours agoAfter Hours Armory LIVE w/ DLD After Dark and Tiberious Gib
14.5K