Monday, March 12, 2018

You don't have to assign a property of the same name to the property you wish to overpower when doctoring objects with the spread operator in TypeScript.

let foo = {
   bar: 13,
   baz: 42,
   qux: 69
};
let qux = 86;
foo = {
   ...foo,
   qux: qux
}
console.log(foo);

 
 

What is above and what is below do the same thing.

let foo = {
   bar: 13,
   baz: 42,
   qux: 69
};
let qux = 86;
foo = {
   ...foo,
   qux
}
console.log(foo);

No comments:

Post a Comment