Skip to main content
Version: 3.28.0

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 with new. Attempting to call it without new throws a TypeError.

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

Return value

A new Set object.