D3.js | d3.map.clear() Function
Last Updated :
28 Jun, 2019
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>
var map = d3.map({ "a" : 1}, { "b" : 2}, { "c" : 3});
map.clear();
A = map.get( "a" );
console.log(A);
</script>
</body>
</html>
|
Output:
undefined
Example 2:
<!DOCTYPE html>
<html>
<head>
<title> d3.map.clear() Function</title>
</head>
<body>
<script>
var map = d3.map({ "a" : 0}, { "b" : 1}, { "c" : 2});
A = map.get( "a" );
console.log(A);
map.clear();
B = map.get( "a" );
console.log(B);
</script>
</body>
</html>
|
Output:
0
undefined
Ref: https://devdocs.io/d3~5/d3-collection#map_clear
Share your thoughts in the comments
Please Login to comment...