Skip to main content
Version: 1.8.0


The Set constructor lets you create Set objects that store unique values of any type, whether primitive values or object references.


new Set()
new Set(iterable)

Note: Set() can only be constructed with new. Attempting to call it without new throws a TypeError.


  • 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 new Set is empty.

Return value

A new Set object.