「JavaScript/Set」の版間の差分
削除された内容 追加された内容
→Polyfill: cleanup. タグ: 2017年版ソースエディター |
→Polyfill: cleanup, more. タグ: 2017年版ソースエディター |
||
113 行
},
intersection: function (other) {
return this.filter(e =>
},
difference: function (other) {
return this.filter(e =>
},
superset_p: function (other) {
130 行
},
}).forEach(pair => {
const [method, func] = pair
Object.defineProperty(Set.prototype,
value:
})
})
b = new Set([2, 3, 4]),
c = new Set([0, 1, 2, 3, 4, 5, 6])
const ary = [
"a",
"b",
console.log(a.map(x => x * 2))▼
"c",
console.log(a.union(b))▼
console.log(a.intersection(b))▼
console.log(a.difference(b))▼
console.log(a.superset_p(c))▼
console.log(a.subset_p(c))▼
]
ary.forEach(x => console.log(x, "=>", eval(x)))
</syntaxhighlight>
;実行結果:<syntaxhighlight lang="text">
a =
b = c => Set(
a.map(x => x * 2) => Set(3) { 0, 2, 4 }
a.union(b) => Set(5) { 0, 1, 2, 3, 4 }
a.intersection(b) => Set(1) { 2 }
a.difference(b) => Set(2) { 0, 1 }
a.superset_p(c) => false
a.subset_p(c) => true
</syntaxhighlight>
|