• <legend id='OD1yE'><style id='OD1yE'><dir id='OD1yE'><q id='OD1yE'></q></dir></style></legend>

    • <bdo id='OD1yE'></bdo><ul id='OD1yE'></ul>

  • <tfoot id='OD1yE'></tfoot>

    <small id='OD1yE'></small><noframes id='OD1yE'>

    <i id='OD1yE'><tr id='OD1yE'><dt id='OD1yE'><q id='OD1yE'><span id='OD1yE'><b id='OD1yE'><form id='OD1yE'><ins id='OD1yE'></ins><ul id='OD1yE'></ul><sub id='OD1yE'></sub></form><legend id='OD1yE'></legend><bdo id='OD1yE'><pre id='OD1yE'><center id='OD1yE'></center></pre></bdo></b><th id='OD1yE'></th></span></q></dt></tr></i><div id='OD1yE'><tfoot id='OD1yE'></tfoot><dl id='OD1yE'><fieldset id='OD1yE'></fieldset></dl></div>

        如何在 JavaScript 中将 Object {} 转换为 Array [] 键值

        时间:2023-08-07
          <legend id='eWZSo'><style id='eWZSo'><dir id='eWZSo'><q id='eWZSo'></q></dir></style></legend>

              <tbody id='eWZSo'></tbody>

                <bdo id='eWZSo'></bdo><ul id='eWZSo'></ul>
                <tfoot id='eWZSo'></tfoot>
                  <i id='eWZSo'><tr id='eWZSo'><dt id='eWZSo'><q id='eWZSo'><span id='eWZSo'><b id='eWZSo'><form id='eWZSo'><ins id='eWZSo'></ins><ul id='eWZSo'></ul><sub id='eWZSo'></sub></form><legend id='eWZSo'></legend><bdo id='eWZSo'><pre id='eWZSo'><center id='eWZSo'></center></pre></bdo></b><th id='eWZSo'></th></span></q></dt></tr></i><div id='eWZSo'><tfoot id='eWZSo'></tfoot><dl id='eWZSo'><fieldset id='eWZSo'></fieldset></dl></div>

                  <small id='eWZSo'></small><noframes id='eWZSo'>

                • 本文介绍了如何在 JavaScript 中将 Object {} 转换为 Array [] 键值对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想像这样转换一个对象:

                  I want to convert an object like this:

                  {"1":5,"2":7,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0}
                  

                  到这样的键值对数组中:

                  into an array of key-value pairs like this:

                  [[1,5],[2,7],[3,0],[4,0]...].
                  

                  如何在 JavaScript 中将 Object 转换为键值对数组?

                  How can I convert an Object to an Array of key-value pairs in JavaScript?

                  推荐答案

                  你可以使用Object.keys()map() 这样做

                  You can use Object.keys() and map() to do this

                  var obj = {"1":5,"2":7,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0}
                  var result = Object.keys(obj).map((key) => [Number(key), obj[key]]);
                  
                  console.log(result);

                  这篇关于如何在 JavaScript 中将 Object {} 转换为 Array [] 键值对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:我如何在 pyqt5 中使用 QTextEdit 来显示 html 的所有 下一篇:JavaScript 关系比较运算符如何强制类型?

                  相关文章

                  最新文章

                    <tfoot id='gUzRY'></tfoot>
                    • <bdo id='gUzRY'></bdo><ul id='gUzRY'></ul>

                    <small id='gUzRY'></small><noframes id='gUzRY'>

                    <i id='gUzRY'><tr id='gUzRY'><dt id='gUzRY'><q id='gUzRY'><span id='gUzRY'><b id='gUzRY'><form id='gUzRY'><ins id='gUzRY'></ins><ul id='gUzRY'></ul><sub id='gUzRY'></sub></form><legend id='gUzRY'></legend><bdo id='gUzRY'><pre id='gUzRY'><center id='gUzRY'></center></pre></bdo></b><th id='gUzRY'></th></span></q></dt></tr></i><div id='gUzRY'><tfoot id='gUzRY'></tfoot><dl id='gUzRY'><fieldset id='gUzRY'></fieldset></dl></div>
                    <legend id='gUzRY'><style id='gUzRY'><dir id='gUzRY'><q id='gUzRY'></q></dir></style></legend>