How to keep the sequence in javascript Map?

后端 未结 2 534
闹比i
闹比i 2021-01-17 17:46

i have myData map as below

 var myData =  new Object();

 myData[10427] = \"Description 10427\";
 myData[10504] = \"Description 10504\";
 myData[10419] = \"D         


        
2条回答
  •  时光说笑
    2021-01-17 18:19

    Objects are unordered in JS. Use an array if order matters.

    var myData = [];
    myData.push({ "number": 10427, description: "Description 10427" });
    

提交回复
热议问题