Set methods
Set methods は数学的な集合演算を Set に追加します。union(), intersection(), difference(), symmetricDifference(), isSubsetOf(), isSupersetOf(), isDisjointFrom() が利用可能です。
概要
Set methods は数学的な集合演算を Set に追加します。union(), intersection(), difference(), symmetricDifference(), isSubsetOf(), isSupersetOf(), isDisjointFrom() が利用可能です。
対応ブラウザ
| 機能 | デスクトップ | モバイル | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 122 | 122 | 127 | 17 | 122 | 17 | |
| ビルトインオブジェクト | ||||||
| intersection() は Set インスタンスのメソッドで、集合を受け取り、この Set と指定された集合の両方にある要素の入った新しい Set を返します。 | 122 | 122 | 127 | 17 | 122 | 17 |
| isDisjointFrom() は Set インスタンスのメソッドで、集合を取り、この Set に与えられた集合と共通する要素がないことを示す論理値を返します。 | 122 | 122 | 127 | 17 | 122 | 17 |
| isSubsetOf() は Set インスタンスのメソッドで、集合を取り、この Set のすべての要素が与えられた集合にあることを示す論理値を返します。 | 122 | 122 | 127 | 17 | 122 | 17 |
| isSupersetOf() は Set インスタンスのメソッドで、集合を取り、与えられた集合のすべての要素がこの Set にあることを示す論理値を返します。 | 122 | 122 | 127 | 17 | 122 | 17 |
| symmetricDifference() は Set インスタンスのメソッドで、集合を受け取り、この Set と与えられた集合のどちらかにあるが、両方にはない要素の入った新しい Set を返します。 | 122 | 122 | 127 | 17 | 122 | 17 |
| union() は Set インスタンスのメソッドで、集合を受け取り、この Set と与えられた集合のどちらかまたは両方にある要素の入った新しい Set を返します。 | 122 | 122 | 127 | 17 | 122 | 17 |
基本構文
const a = new Set([1, 2, 3, 4]);
const b = new Set([3, 4, 5, 6]);
a.union(b); // Set {1, 2, 3, 4, 5, 6}
a.intersection(b); // Set {3, 4}
a.difference(b); // Set {1, 2}
a.symmetricDifference(b); // Set {1, 2, 5, 6}
a.isSubsetOf(b); // false
a.isSupersetOf(b); // false ライブデモ
collectioncombine. Union (union)
2. collectioncombine unified, all. Duplicates element read..
commonpartial. Extract (intersection)
2. collectioncombine. both to includeelement(commonskil etc) extract..
Difference. Extract (difference)
oneside. collectioncombine to with, otherside to is element(not-aitemu etc) extract..
実務での使いどころ
-
Set methods の活用
Set に集合演算メソッドを追加。union, intersection, difference, symmetricDifference 等を提供。
注意点
- 古いブラウザ(IE等)では対応していない。対象ブラウザを確認すること。
アクセシビリティ
- JavaScript による動的更新時は、aria-live リージョンで変更をスクリーンリーダーに通知する。
参考リンク
Powered by web-features