Standard built-ins

Set.prototype.add()

Try the free JavaScript compiler

Insert a member if not already present; return receiver.

Formal Syntax & Structure

javascript syntaxjavascript
set.add(value)

Parameters & Attributes

NameTypeDescription
valueAnyValue to associate or insert.

Return Value

Set

Same set.

Working Example

Example Snippetjavascript
const s=new Set();console.log(s.add(3)===s);
JavaScript Reference