★ wanayoo — archive 1999 https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Set/addNouvelle recherche | Portail wanayoo

Join MDN and developers like you at Mozilla's View Source conference, November 2-4 in Portland, Oregon. Learn more at https://viewsourceconf.org/.

Set.prototype.add()

by 1 contributor:

This article is in need of an editorial review.

This translation is incomplete. Please help translate this article from English.

これは Harmony(ECMAScript 6) 提案の一部であり、実験段階の技術です。
この技術の仕様は安定していません。ブラウザ互換性の一覧表を確認してください。またこれらの構文や動作は、仕様変更などにより、新しいバージョンのブラウザでは変更される可能性があるという点に注意してください。

概要

特定のvalueをもつ新しい要素をSetオブジェクトの最後に追加します。

構文

mySet.add(value);

引数

value
必須。Setオブジェクトに追加する要素の値。

戻り値

Setオブジェクト。

例

例: add メソッドを使う

var mySet = new Set();

mySet.add(1);
mySet.add(5).add("some text"); // chainable

console.log(mySet);
// Set [1, 5, "some text"]

仕様

仕様 状況 コメント
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'Set.prototype.add' in that specification.
Standard Initial definition.

ブラウザ実装状況

機能 Chrome Firefox (Gecko) Internet Explorer Opera Safari
基本サポート 38 13.0 (13.0) 11 25 7.1
機能 Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
基本サポート 未サポート 38 13.0 (13.0) 未サポート 未サポート iOS 8

Firefox固有のメモ

  • Firefox 33 (Firefox 33 / Thunderbird 33 / SeaMonkey 2.30)以前では、 Set.prototype.addはundefinedを返し、チェーンできませんでした。これは、(バグ 1031632)でFIXされました。 Chrome/v8(issue)でも同様の振る舞いが見つかります。

関連情報

ドキュメントのタグと貢献者

Contributors to this page: shide55
最終更新者: shide55,