Entiende el código de forma correcta antes de aplicarlo a tu trabajo y si ttienes algo que aportar puedes comentarlo.
Ejemplo 1: fusionar dos objetos javascript
const object1 =
name:'Flavio'const object2 =
age:35const object3 =...object1,...object2 //name: "Flavio", age: 35
Ejemplo 2: fusionar objetos javascript
const a = b:1, c:2;const d = e:1, f:2;const ad =...a,...d ;// b: 1, c: 2, e: 1, f: 2
Ejemplo 3: fusionar objetos js
/* For the case in question, you would do: */
Object.assign(obj1, obj2);/** There's no limit to the number of objects you can merge.
* All objects get merged into the first object.
* Only the object in the first argument is mutated and returned.
* Later properties overwrite earlier properties with the same name. */const allRules = Object.assign(, obj1, obj2, obj3, etc);
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)