.add()

The .add() method inserts a value into a Set (if it is unique) and returns the updated Set object.

Syntax

set.add(value);

The value in set is unique and of a valid data type.

Codebyte Example

Code
Output
Loading...

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn JavaScript on Codecademy