Tuesday, April 10, 2018

Assignments from a variable to a property of the same name at an object may be simplified in TypeScript.

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

 
 

...is the same as...

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

 
 

The former in TypeScript will make the later in JavaScript.

No comments:

Post a Comment