You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Combines an array of objects, where only the top-level objects are merged. This means that if the objects being merged contain nested objects, those nested object aren't deeply merged; instead, they're replaced entirely by the corresponding property from the merging object.
430
+
Combines an array of objects, where only the top-level objects are merged. This means that if the objects being merged contain nested objects, those nested object aren't deeply merged. Instead, they're replaced entirely by the corresponding property from the merging object.
**firstOutput** shows the properties from the merging objects are combined into a new object. If there are conflicting properties (i.e., properties with the same name), the property from the last object being merged usually takes precedence.
463
+
**firstOutput** shows the properties from the merging objects are combined into a new object. If there are conflicting properties (that is, properties with the same name), the property from the last object being merged usually takes precedence.
426
464
427
465
**secondOutput** shows the shallow merge doesn't recursively merge these nested objects. Instead, the entire nested object is replaced by the corresponding property from the merging object.
| arg1 |Yes |array or object |The first value to use for joining elements. |
442
480
| arg2 |Yes |array or object |The second value to use for joining elements. |
443
-
| additional arguments |No |array or object |Additional values to use for joining elements. |
481
+
| additional arguments |No |array or object |More values to use for joining elements. |
444
482
445
483
### Return value
446
484
@@ -450,15 +488,15 @@ An array or object.
450
488
451
489
The union function uses the sequence of the parameters to determine the order and values of the result.
452
490
453
-
For arrays, the function iterates through each element in the first parameter and adds it to the result if it isn't already present. Then, it repeats the process for the second parameter and any additional parameters. If a value is already present, it's earlier placement in the array is preserved.
491
+
For arrays, the function iterates through each element in the first parameter and adds it to the result if it isn't already present. Then, it repeats the process for the second parameter and any other parameters. If a value is already present, it's earlier placement in the array is preserved.
454
492
455
493
For objects, property names and values from the first parameter are added to the result. For later parameters, any new names are added to the result. If a later parameter has a property with the same name, that value overwrites the existing value. The order of the properties isn't guaranteed.
456
494
457
495
The union function merges not only the top-level elements but also recursively merges any nested objects within them. Nested array values aren't merged. See the second example in the following section.
458
496
459
497
### Example
460
498
461
-
The following example shows how to use union with arrays and objects:
499
+
The following example shows how to use `union` with arrays and objects:
0 commit comments