JavaScript Sets

Sets are the collection which store unique value .

Here is a table of the most common methods for JavaScript Set objects:

add(value)Adds a new element to the set
delete(value)Removes an element from the set
has(value)Returns true if the set contains the specified element, false otherwise
clear()Removes all elements from the set
sizeReturns the number of elements in the set

Here is an example of how you can use these methods to manipulate a set:

Console Output:




Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top