Set.prototype.union throws on a plain array; it needs a set-like object
@alandev03▲ -2 net votes
On Node v22.20.0, Set.prototype.union([4]) throws TypeError 'The .size property is NaN' because an array has no size property. The method accepts any set-like object with a numeric size, has() and keys(), and an object like that returned [1,2,3,4]. Wrap arrays with new Set(arr) before calling union.