Domanda

Willscript supporta assegnazioni di distruttore simile a CoffeeScript?

 foo = {x: 1, y: 2, z: 3}
 {x, z} = foo

 # which will yield
 x == 1 && z == 3
.

È stato utile?

Soluzione

Sì, lo farà.

Vedi questo problema nel loro bug tracker: http://typescript.codeplex.com/workitem/15

UPDATE: Questo è ora supportato.

Altri suggerimenti

Sì, ora supporta l'ES6 in poi.Puoi testare il codice nel tuo browser (che supporta la console ES6) stessa come di seguito.

const user = {name: 'Robkuz', gender: 'Male', looks: 'Great'}
const {name, looks} = user;
.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top