create and initialize dictionary in typescript in same line -




i want create dictionary using typescript , initialize in same line instead of first creating , populating value below

var persons: { [id: string] : iperson; } = {}; persons["p1"] = { firstname: "f1", lastname: "l1" }; 

how combine above one?

just create object. objects in ecmascripts associative arrays.

here example object:

const persons: { [id: string] : iperson; } = {   p1: { firstname: "f1", lastname: "l1" } }; 

it's better use const or let instead of var.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -