Underscore.js _.keys() Function
Underscore.js_.keys() function is used to return the list of all keys of the given object.
Syntax:
_.keys( object );Parameters:
- object: It contains the object elements.
Return Value:
This function returns the list of all keys of the given object.
Example 1: This example shows the use of the _.keys() function.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src=
"https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js">
</script>
</head>
<body>
<script type="text/javascript">
let obj = {
Company: "GeeksforGeeks",
Address: "Noida",
Contact: "+91 9876543210",
Email: "abc@gfg.com"
}
console.log(_.keys(obj));
</script>
</body>
</html>
Output:

Example 2: This example shows the use of the _.keys() function.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src=
"https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js">
</script>
</head>
<body>
<script type="text/javascript">
let key = _.keys({
Name: "Ashok",
Address: "Noida",
Mobile: "+91 9876543210",
Email: "geeks@gmail.com"
});
console.log(key);
</script>
</body>
</html>
Output: