D3.js | d3.map.get() Function Last Updated : 28 Jun, 2019 Comments Improve Suggest changes Like Article Like Report The map.get() function in D3.js is used to return the value for the specified key string. If the created map does not contain the specified key then it returns undefined. Syntax: map.get(key) Parameters: This function accepts single parameter key which is used to specify the key string. Return Value: This function returns the value for the specified key string. If the created map does not have an entry for the specified key, returns undefined. Below programs illustrate the d3.map.get() function in D3.js: Example 1: javascript <!DOCTYPE html> <html> <head> <title>d3.map.get() function</title> <script src='https://d3js.org/d3.v4.min.js'></script> </head> <body> <script> // Creating a map var map = d3.map({"Ram": 5}); // Calling the map.get() function A = map.get("Ram"); // Getting the value for the "Ram" key console.log(A); </script> </body> </html> Output: 5 Example 2: javascript <!DOCTYPE html> <html> <head> <title>d3.map.get() function</title> <script src='https://d3js.org/d3.v4.min.js'></script> </head> <body> <script> // Creating a map var map1 = d3.map({"Ram": 5}); var map2 = d3.map({"Geeks": 10}); var map3 = d3.map({"Ram": 5}, {"Geeks": 10}); var map4 = d3.map(); // Calling the map.get() function A = map1.get("Ram"); B = map2.get("Geeks"); C = map3.get("Geeks"); D = map3.get("Ram"); E = map4.get("Geeks"); // Getting the values for // the specified keys console.log(A); console.log(B); console.log(C); console.log(D); console.log(E); </script> </body> </html> Output: 5 10 undefined 5 undefined Ref: https://devdocs.io/d3~5/d3-collection#map_get Comment More infoAdvertise with us Next Article D3.js | d3.map.get() Function K Kanchan_Ray Follow Improve Article Tags : JavaScript Web Technologies D3.js Similar Reads D3.js | d3.map.has() Function The map.has() function in D3.js is used to return true if the created map has an entry for specified key string. The value of map.has() function may be null or undefined. Syntax: map.has(key) Parameters: This function accepts single parameter key which is specified the key string. Return Value: This 2 min read D3.js d3.max() function The d3.max() function in D3.js is used to return the maximum value in the given array using natural order. If an array is empty then it returns undefined as output. Syntax:d3.max(Array)Parameters:This function accepts parameters Array which is an array of elements whose maximum value is to be calcul 2 min read D3.js | d3.map.set() Function The map.set() function in D3.js used to set the values for the specified key string in to the created map. Syntax: d3.map.set(key, value); Parameters: This function accepts two parameters which are illustrated below: key: This is the key string. value: This is the corresponding value for each key st 2 min read D3.js | d3.sum() function The d3.sum() function in D3.js is used to return the sum of the given array's elements. If the array is empty then it returns 0. Syntax: d3.sum(Array) Parameters: This function accepts a parameters Array which is an array of elements whose sum are to be calculated. Return Value: It returns the sum o 2 min read D3.js | d3.map.keys() Function The map.keys() function in D3.js is used to return an array of string keys for every entry in the created map. The order of the returned keys is arbitrary. Syntax: map.keys() Parameters: This function does not accept any parameters. Return Value: This function returns an array of string keys for eve 2 min read Like