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
Post a Comment