D3.js | d3.map.clear() Function
The map.clear() function in D3.js used to remove all the entries from the created map.
Syntax:
d3.map.clear();
Parameters: This function does not accept any parameter.
Return Value: This function does not return any values.
Below programs illustrate the d3.map.clear() function in D3.js:
Example 1:
<!DOCTYPE html> <html> <head> <title> d3.map.clear() Function</title> </head> <body> <script> // Creating a map var map = d3.map({"a": 1}, {"b": 2}, {"c": 3}); // Calling the map.clear() function map.clear(); // Checking whether the value for the specified key // is present or not A = map.get("a"); // Getting the output either value of the specified key // string or undefined if the key is not present console.log(A); </script> </body> </html> |
chevron_right
filter_none
Output:
undefined
Example 2:
<!DOCTYPE html> <html> <head> <title> d3.map.clear() Function</title> </head> <body> <script> // Constructing a map var map = d3.map({"a": 0}, {"b": 1}, {"c": 2}); // Checking whether the value for the specified key // is present or not before calling clear() function A = map.get("a"); // Getting the output of value console.log(A); // Calling the map.clear() function map.clear(); // Checking whether the value for the specified key // is present or not after calling clear() function B = map.get("a"); // Getting the output of value console.log(B); </script> </body> </html> |
chevron_right
filter_none
Output:
0 undefined
Ref: https://devdocs.io/d3~5/d3-collection#map_clear
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 ?
- PHP | end() Function
- p5.js | hex() function
- D3.js | d3.rgb() Function
- PHP | pow( ) Function
- D3.js | d3.hcl() Function
- CSS | hsl() Function
- CSS | var() Function
- PHP | next() Function
- PHP | Ds\Set xor() Function
- p5.js | str() function
- PHP | dir() Function
- D3.js | d3.lab() 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.



