When I want get Object by key I have undefined each all element.
My Map :
nodesMaps : Map<number, Object> = [
{ key: "1", value: Object },
{ key: "2", value: Object },
{ key: "3", value: Object },
]
When I want get value of this map :
this.nodesMaps.get(1) // return undefined
this.nodesMaps.get("1") // return undefined
below code for me..
let map = new Map([
[ "A", "AA" ],
[ "B", "BB" ],
[ "C", "CC" ]
]);
console.log(map.get("A"));
check this: https://jsfiddle.net/vipinmpd08/1b68eLdr/91920/
You've messed many things.
Map, you assigned an Array value.Valid map creation should look like this:
let nodesMap = new Map([
[1, 'foo'],
[2, 'bar'],
[3, 'baz'],
])
console.log(nodesMap.get(1)) // foo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With