D3.js | d3.map.set() Function Last Updated : 30 Oct, 2019 Comments Improve Suggest changes Like Article Like Report 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 string. Return Value: This function does not return any values. Below programs illustrate the d3.map.set() function in D3.js: Example 1: javascript <!DOCTYPE html> <html> <head> <title>d3.map.set() function</title> <script src = "https://d3js.org/d3.v4.min.js"></script> </head> <body> <script> // Creating a map var map = d3.map() // setting the value for the specified key string // into above map .set("a", 1).set("b", 2).set("c", 3); // Getting the value for the specified key string A = map.get("a"); B = map.get("c"); // Printing the output of values console.log(A); console.log(B); </script> </body> </html> Output: 1 3 Example 2: javascript <!DOCTYPE html> <html> <head> <title>d3.map.set() function</title> <script src = "https://d3js.org/d3.v4.min.js"></script> </head> <body> <script> // Creating a map and setting the value // for the specified key string var map = d3.map().set("Geeks", 1).set("Geek", 2).set("gfg", 3); // Getting the value for the specified key string A = map.get("Geek"); B = map.get("c"); // Printing the output of values console.log(A); console.log(B); </script> </body> </html> Output: 2 undefined Note: In the above code, the string "c" is not present in the created map that is why undefined is printed as output. Ref: https://devdocs.io/d3~5/d3-collection#map_set Comment More infoAdvertise with us Next Article D3.js | d3.map.set() Function K Kanchan_Ray Follow Improve Article Tags : JavaScript Web Technologies D3.js Similar Reads D3.js | d3.map.size() Function The map.size() function in D3.js is used to return the number of entries in the created map. Syntax: map.size() Parameters: This function does not accept any parameters. Return Value: This function returns the number of entries in the created map. Below programs illustrate the d3.map.size() function 1 min read D3.js nest.map() Function nest.map() function in D3.js is used to form a nested map. The map contains a key-value pair determined by the key function which was executed very first. If no keys are declared or defined than map function returns the original array as it is. Syntax: nest.map(array) Parameters: It takes the collec 2 min read D3.js | d3.map.values() Function The map.values() function in D3.js used to return an array of values for every entry in the created map. The order of the returned values are arbitrary. Syntax: d3.map.values() Parameters: This function does not accept any parameters. Return Value: This function returns an array of values for every 2 min read D3.js | d3.map.remove() Function The map.remove() function is an inbuilt function in D3.js. If the created map contains the given key string then it removes the entry and returns true. If key string not presents then it returns false. Syntax: map.remove(key) Parameters: This function accepts single parameter key which is used to sp 2 min read D3.js | d3.set.remove() function The set.remove() is a function in D3.js. If the given array contains the specified value then removes it and returns true. Otherwise, this function does nothing and returns false. Syntax: d3.set([Array]).remove(element); Parameters: This function accepts two parameters which are illustrated below: A 2 min read Like