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

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

        <tfoot id='n7lC8'></tfoot>
        • <bdo id='n7lC8'></bdo><ul id='n7lC8'></ul>
      1. 将两个数组(键和值)合并为一个对象

        merge two arrays (keys and values) into an object(将两个数组(键和值)合并为一个对象)

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

            <bdo id='Iq3Gw'></bdo><ul id='Iq3Gw'></ul>

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

                    <tbody id='Iq3Gw'></tbody>
                  本文介绍了将两个数组(键和值)合并为一个对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  Is there a common Javascript/Coffeescript-specific idiom I can use to accomplish this? Mainly out of curiosity.

                  I have two arrays, one consisting of the desired keys and the other one consisting of the desired values, and I want to merge this in to an object.

                  keys = ['one', 'two', 'three']
                  values = ['a', 'b', 'c']
                  

                  解决方案

                  var r = {},
                      i,
                      keys = ['one', 'two', 'three'],
                      values = ['a', 'b', 'c'];
                  
                  for (let i = 0; i < keys.length; i++) {
                      r[keys[i]] = values[i];
                  }
                  
                  console.log(r);

                  .as-console-wrapper { max-height: 100% !important; top: 0; }

                  这篇关于将两个数组(键和值)合并为一个对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)
                  Rails 3.1 ajax:success handling(Rails 3.1 ajax:成功处理)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                  Ordinals in words javascript(javascript中的序数)
                  getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)

                    <bdo id='BoLhq'></bdo><ul id='BoLhq'></ul>

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

                          <tbody id='BoLhq'></tbody>
                        • <tfoot id='BoLhq'></tfoot>
                          1. <small id='BoLhq'></small><noframes id='BoLhq'>