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:
- Array: This is an given array of elements as string.
- element: This is the value which is going to be searched into the given array and removes it if present and returns true otherwise does nothing and returns false.
Return Value: It returns true if the given array contains the specified value Otherwise, returns false.
Note: It does not hold the updated array.
Below programs illustrate the d3.set.remove() function in D3.js.
Example 1:
<!DOCTYPE html> <html> <head> <title> d3.set.remove() Function</title> </head> <body> <script> // Initialising an array Array1 = ["a", "a", "b", "c"]; Array2 = ["c", "c", "c"]; Array3 = ["Geeks", "gfg", "GeeksforGeeks"]; // Calling the d3.set.remove() function A = d3.set(Array1).remove("a"); B = d3.set(Array2).remove("a"); C = d3.set(Array3).remove("Geeks"); // Getting the value true if the specified element // is present in the array otherwise false console.log(A); console.log(B); console.log(C); </script> </body> |
Output:
true false true
Example 2:
<!DOCTYPE html> <html> <head> <title> d3.set.remove() Function</title> </head> <body> <script> // Calling the d3.set.remove() function // with a array and a element as the parameter A = d3.set([1, 2, 3, 3]).remove(4); B = d3.set(["a"]).remove("a"); C = d3.set(["a", "b", "c", "a", "b", "c"]).remove("d"); // Getting the value true if the specified element // is present in the array otherwise false console.log(A); console.log(B); console.log(C); </script> </body> |
Output:
false true false
Ref: https://devdocs.io/d3~5/d3-collection#set_remove
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.

