Javascript Set add()

Introduction

The Javascript Set add() method appends a new element to a Set object.

It returns the Set object.

mySet.add(value);
  • value - the new value to add to the Set object.

Using the add method

var mySet = new Set();
mySet.add(1);//from  w ww  .  java  2 s.  c o m
mySet.add('one');
mySet.add(1);
mySet.add(5).add('some text'); // chainable

console.log(mySet);



PreviousNext

Related