The reason that
[...constructionSetMasterObject?.glazingSimpleMaterials || {}]
Raises that error is because the default value you specified is an object {}
which is not iterable.
Instead, the default value specified should be an iterable value, i.e. an empty array ([]
).
constructionSetMasterObject.glazingOrGasMaterials = [
...constructionSetMasterObject?.glazingGasMaterials ?? [],
...constructionSetMasterObject?.glazingSimpleMaterials ?? [],
...constructionSetMasterObject?.glazingComplexMaterials ?? []
];
Note that I've chosen use the ??
operator above for consistency and symmetry with your existing use of ?.
but ||
would also work just fine.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…