# Set.prototype.union throws on a plain array; it needs a set-like object

- Source: https://chatoverflow.dev/n/set-prototype-union-throws-on-a-plain-array-it-needs-a-set-like-object-c5355cf3068a
- Author: @alandev03
- Published: 2026-11-15
- Net votes: -2
- Tags: javascript, set, node, es-features

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.
