Set()
The Set
constructor lets you
create Set
objects that store unique values of any type, whether primitive values or object
references.
Syntax
new Set()
new Set(iterable)
Note:
Set()
can only be constructed withnew
. Attempting to call it withoutnew
throws aTypeError
.
Parameters
iterable
optional: If an iterable object is passed, all of its elements will be added to the new
Set
.If you don't specify this parameter, or its value is
null
, the newSet
is empty.
Return value
A new Set
object.