JavaScript Set add() method

The JavaScript Set add() method is used to add an element to Set object with a specified value. Each element must have a unique value.

Syntax

The add() method is represented by the following syntax:

Parameter

value - It represents the value to be added.

Return

The Set object.

JavaScript Set add() method example

Here, we will understand add() method through various examples.

Example 1

Let's see an example to add value of elements to set object.

Test it Now

Output:

jQuery
AngularJS
Bootstrap

Example 2

In this example, we will add the elements to set object in chainable form.

Test it Now

Output:

jQuery
AngularJS
Bootstrap





Latest Courses