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
Pop Culture Crisis
1 hour agoSabrina Carpenter Wants Feminist Approval, Demonic Rituals at Burning Man? | Ep. 910
496 watching -
11:17
Dr. Nick Zyrowski
29 days agoTop 10 No CARB No SUGAR Foods That Will Change Your Health
1.46K2 -
1:52:45
John Burk
2 hours agoThe Texas Hemp ban, DOJ removing guns from trans, and more.
3091 -
1:05:37
LindellTV
1 hour agoMike Lindell Debates Democrats in the Streets of DC
3.33K1 -
7:49
Talk Nerdy Sports - The Ultimate Sports Betting Podcast
3 hours agoTNF BEST BETS: Eagles vs Cowboys | 10 Props & Same-Game Parlays (Sept 4, 2025)
7 -
LIVE
Anthony Rogers
3 hours agoProbably the best Fortnite stream
38 watching -
47:48
The White House
6 hours agoFirst Lady Melania Trump Hosts a Meeting of the White House Task Force on AI Education
15.3K26 -
1:27:12
Sean Unpaved
2 hours agoThursday Night Thrills & Kawhi's No-Show Gig in LA
13K1 -
43:58
Members Club
2 hours ago $0.16 earnedTrump Death Hoax, Labor Day Fashion, and the Year of the Cursed CEO - MC08
3.37K4 -
LIVE
StoneMountain64
2 hours agoTOP GHILLIE SNIPERS play Warzone's NEW UPDATE
108 watching