ES6 Sets

set functions and their usage

A Set data structure in ES6 is an ordered list of unique elements. Here are some set functions and their usage:

Keyword Type Usage
Set constructor creates a set
add method adds elements to the set
size property check size of the set
has method check if an element is a member of the set
delete method remove a value from a set

Consider the following code:

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.