Underscore _.get() Function Last Updated : 01 Feb, 2022 Comments Improve Suggest changes Like Article Like Report Underscore.js is a JavaScript library that provides a lot of useful functions that help in the programming in a big way like the map, filter, invokes, etc even without using any built-in objects. The _.get() function is an inbuilt function in the Underscore.js library of JavaScript which is used to get the value at the path of object. If the resolved value is undefined, the defaultValue is returned in its place. Syntax: _.get(object, path, [defaultValue])Parameters: This method accepts three parameters as mentioned above and described below: object: This parameter holds the object to query.path: This parameter holds the path of the property to get. The path will be array or string.defaultValue: This parameter holds the value returned for undefined resolved values.Return Value: This method returns the resolved value.Example 1: HTML <!DOCTYPE html> <html> <head> <script src= "https://cdn.jsdelivr.net/npm/[email protected]/underscore-umd-min.js"> </script> </head> <body> <script> // Given object var object = { 'c': [{ 'python': { 'java': 3 } }] }; // Use of _.get method console.log(_.get(object, 'c')); </script> </body> </html> Output: [{ 'python': { 'java': 3 } }] Example 2: HTML <!DOCTYPE html> <html> <head> <script src= "https://cdn.jsdelivr.net/npm/[email protected]/underscore-umd-min.js"> </script> </head> <body> <script> // Given object var object = { 'c': [{ 'python': { 'java': 3 } }] }; // Use of _.get method console.log(_.get(object, ['c', '0', 'python', 'java'])); </script> </body> </html> Output: 3Example 3: HTML <!DOCTYPE html> <html> <head> <script src= "https://cdn.jsdelivr.net/npm/[email protected]/underscore-umd-min.js"> </script> </head> <body> <script> // Given object var object = { 'c': [{ 'python': { 'java': 3 } }] }; // Use of _.get method console.log(_.get(object, 'c.python.java', 'default')); </script> </body> </html> Output: defaultReference: https://underscorejs.org/#get Comment More infoAdvertise with us Next Article Underscore _.get() Function S SHUBHAMSINGH10 Follow Improve Article Tags : JavaScript Web Technologies JavaScript - Underscore.js underscore Similar Reads Underscore.js _.rest() Function The Underscore.js is a JavaScript library that provides a lot of useful functions like the map, filter, invoke etc even without using any built-in objects. The _.rest() is used to return the rest of the elements except the zeroth indexed element. Second parameter is used to start the search from the 3 min read Underscore.js _.tap() Function Underscore.js is a JavaScript library that provides a lot of useful functions that help in the programming in a big way like the map, filter, invoke, etc even without using any built-in objects. The _.tap() function is an inbuilt function in Underscore.js library of JavaScript which is used to call 2 min read Underscore.js _.range() Function _.range() function: It is used to print the list of elements from the start given as a parameter to the end also a parameter. The start and step parameters are optional. The default value of start is 0 and that of step is 1. In the list formed the start is inclusive and the stop is exclusive. The st 3 min read Underscore.js _.result() Function Underscore.js is a JavaScript library that provides a lot of useful functions that helps in the programming in a big way like the map, filter, invoke etc even without using any built-in objects. The _.result() function is an inbuilt function in Underscore.js library of JavaScript. Here, if the state 2 min read Underscore.js _.reject Function The Underscore.js is a JavaScript library that provides a lot of useful functions that helps in the programming in a big way like the map, filter, invoke etc even without using any built-in objects. The _.reject() function is used to give the answer which does not match with the given condition. It 3 min read Like