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
-
3:28:35
Spartan
4 hours agoSpartan - Pro Halo Player for OMiT | Scrims vs Mindfreak then ranked (probably)
8.3K2 -
LIVE
GritsGG
4 hours agoWin Streaking! Most Wins 3180+! 🔥
341 watching -
LIVE
LumpyPotatoX2
9 hours agoKilling Floor 3 + SoulFrame: Co-op Showcase - #RumbleGaming
649 watching -
2:10:50
vivafrei
9 hours agoEp. 274: Canada's War on Christianity! Is Candace Owens Cooked? SCOTUS, RFK Jr. AND MORE!
94.5K218 -
38:09
The Mel K Show
7 hours agoMel K & Tim James | Are Hidden Dangers Lurking in Your Mouth? | 7-27-25
41.2K7 -
3:38:01
sophiesnazz
3 hours agoTIME TO WIND PEOPLE UP !socials
13.1K1 -
GamerGril
4 hours agoDoom Gal Bingo The Finale | Special Boss Bingo
10.5K5 -
2:22:46
The Connect: With Johnny Mitchell
1 day ago $16.52 earnedOne Man's Mission To Stop Human Trafficking: How A Billionaire Mercenary Saved Hundreds Of Children
67.8K41 -
5:16:39
FoeDubb
4 hours ago🏰KINGDOM MENU:🌳SESHYS & 🎮WITCHER 3 VIBES ON DECK DILLY DILLY!!!
9.2K2 -
28:43
Liberty Hangout
4 days agoAnti-Trumpers Don't Know What They're Protesting
64.7K252