JavaScript associate array

前端 未结 5 2016
栀梦
栀梦 2020-12-15 03:46

In Python I could do something like myMap = {key: [value1, value2]} and then access the value2 using myMap[key][1]

Can I do som

5条回答
  •  时光说笑
    2020-12-15 04:08

    You can use Map:

    var myMap = new Map();
    myMap.set('key','Value');
    var res = myMap.get('key');
    
    console.log(var); // Result is: 'Value'
    

提交回复
热议问题