js
setA.union(setB)دي من ES2025، فبدل ما تكتب loop بتجمع، بقت سطر واحد. أي argument مش Set بيترمي TypeError.
البرهان
js
const a = new Set([1, 2]);
const b = new Set([2, 3]);
console.log([...a.union(b)], [...a]);النتيجة
[ 1, 2, 3 ] [ 1, 2 ]