Underscore.js _.keys() Function
Last Updated :
13 Jan, 2024
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.
html
<!DOCTYPE html>
< html >
< head >
< script type = "text/javascript" src =
</ 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.
html
<!DOCTYPE html>
< html >
< head >
< script type = "text/javascript" src =
</ 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:
Share your thoughts in the comments
Please Login to comment...