D3.js | d3.set.clear() Function
The set.clear() function in D3.js is used to remove all values from the set. It clears the set and holds that blank set you can check that in the 2nd example.
Syntax:
d3.set().clear();
Parameters: This function does not accept any parameters.
Return Value: This function does not returns any values.
Below programs illustrate the d3.set.clear() function in D3.js:
Example 1:
<!DOCTYPE html>
<html>
<head>
<title> d3.set.clear() Function</title>
</head>
<body>
<script>
var set = d3.set([ "1" , "2" , "a" , "b" , "Geeks" ]);
console.log(set);
set.clear();
A = set.has( "a" );
B = set.has( "Geeks" );
console.log(A);
console.log(B);
</script>
</body>
</html>
|
Output:
{"$1":"1","$2":"2","$a":"a","$b":"b","$Geeks":"Geeks"}
false
false
Example 2:
<!DOCTYPE html>
<html>
<head>
<title> d3.set.clear() Function</title>
</head>
<body>
<script>
var set = d3.set([ "1" , "2" , "a" , "b" , "Geeks" ]);
A = set.has( "a" );
B = set.has( "Geeks" );
console.log(A);
console.log(B);
set.clear();
C = set.has( "a" );
D = set.has( "Geeks" );
console.log(C);
console.log(D);
</script>
</body>
</html>
|
Output:
true
true
false
false
Ref: https://devdocs.io/d3~5/d3-collection#set_clear
Last Updated :
28 Jun, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...