← 返回首页
Set.prototype.add() - JavaScript | MDN

Esta página ha sido traducida del inglés por la comunidad. Aprende más y únete a la comunidad de MDN Web Docs.

View in English Always switch to English

Set.prototype.add()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since julio de 2015.

El método add() añade un nuevo elemento con un valor específico al final del objeto Set.

In this article

Sintaxis

mySet.add(value);

Parameters

value

Requerido. El valor del elemento a ser añadido al objeto Set.

Return value

El objeto Set.

Ejemplos

Usando el método add

js
var mySet = new Set(); mySet.add(1); mySet.add(5).add("some text"); // chainable console.log(mySet); // Set [1, 5, "some text"]

Especificaciones

Specification
ECMAScript® 2027 Language Specification
# sec-set.prototype.add

Compatibilidad con navegadores

Enable JavaScript to view this browser compatibility table.

Ver también