D3.js | d3.entries() Function
The d3.entries() function in D3.js is used to return an array containing the property names and property values of the specified object or an associative array.
Syntax:
d3.entries(object)
Parameters: This function accepts single parameter object containing key and value in pairs.
Return Value: It returns an array containing the property names and values of the specified object or an associative array.
Below programs illustrate the d3.entries() function in D3.js:
Example 1:
<!DOCTYPE html> <html> <head> <title> d3.entries() function </title> </head> <body> <script> // Initialising an object var month = { "January" : 1, "February" : 2, "March" : 3}; // Calling the d3.entries() function A = d3.entries(month); // Getting the key and value in pairs console.log(A); </script> </body> </html> |
Output:
[{"key":"January","value":1},{"key":"February","value":2}, {"key":"March","value":3}]
Example 2:
<!DOCTYPE html> <html> <head> <title> d3.entries() function </title> </head> <body> <script> // Initialising an object var month = { "GeeksforGeeks" : 0, "Geeks" : 2, "Geek" : 3, "gfg" : 4}; // Calling the d3.entries() function A = d3.entries(month); // Getting the key and value in pairs. console.log(A); </script> </body> </html> |
Output:
[{"key":"GeeksforGeeks","value":0},{"key":"Geeks","value":2}, {"key":"Geek","value":3},{"key":"gfg","value":4}]
Reference: https://devdocs.io/d3~5/d3-collection#entries
Recommended Posts:
- How to call a function that return another function in JavaScript ?
- How to get the function name inside a function in PHP ?
- How to get the function name from within that function using JavaScript ?
- D3.js | d3.map.set() Function
- PHP | pos() Function
- PHP | max( ) Function
- PHP | Ds\Map put() Function
- PHP | each() Function
- PHP | key() Function
- PHP | min( ) Function
- p5.js | pan() Function
- p5.js | nfc() function
- p5.js | nfp() Function
- p5.js | nfs() Function
- PHP | Ds\Set xor() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.