D3.js | d3.set.add() Function
The set.add() function in D3.js is used to add the specified value string to the created set.
Syntax:
d3.set().add(element);
Parameters: This function accepts single parameter element which is going to be added into the created set.
Return Value: This function does not returns any values.
Below programs illustrate the d3.set.add() function in D3.js:
Example 1:
<!DOCTYPE html> <html> <head> <title> d3.set.add() Function</title> </head> <body> <script> // Initialising the set var set = d3.set() .add( "Geeks" ) .add( "Geeks" ) .add( "gfg" ); // Checking whether the desired element is // present or not A = set.has( "GeeksforGeeks" ); B = set.has( "Ram" ); C = set.has( "Geeks" ); // Getting the output of true or false console.log(A); console.log(B); console.log(C); </script> </body> </html> |
Output:
false false true
Example 2:
<!DOCTYPE html> <html> <head> <title> d3.set.add() Function</title> </head> <body> <script> // Initialising the set var set = d3.set().add( "a" ).add(1).add(123); // Checking whether the desired element is // present or not A = set.has( "a" ); B = set.has(123); C = set.has(5); // Getting the output of true or false console.log(A); console.log(B); console.log(C); </script> </body> </html> |
Output:
true true false
Ref: https://devdocs.io/d3~5/d3-collection#set_add
Recommended Posts:
- How to call a function that return another function in JavaScript ?
- How to get the function name from within that function using JavaScript ?
- How to get the function name inside a function in PHP ?
- PHP | pos() Function
- PHP | key() Function
- D3.js | d3.map.set() Function
- PHP | Ds\Set add() Function
- PHP | end() Function
- p5.js | log() function
- p5.js | sin() function
- p5.js | cos() function
- PHP | Ds\Map xor() Function
- PHP | abs() Function
- p5.js | max() function
- D3.js | d3.hcl() 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.