久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <tfoot id='DKgE3'></tfoot><legend id='DKgE3'><style id='DKgE3'><dir id='DKgE3'><q id='DKgE3'></q></dir></style></legend>

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

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

      <i id='DKgE3'><tr id='DKgE3'><dt id='DKgE3'><q id='DKgE3'><span id='DKgE3'><b id='DKgE3'><form id='DKgE3'><ins id='DKgE3'></ins><ul id='DKgE3'></ul><sub id='DKgE3'></sub></form><legend id='DKgE3'></legend><bdo id='DKgE3'><pre id='DKgE3'><center id='DKgE3'></center></pre></bdo></b><th id='DKgE3'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='DKgE3'><tfoot id='DKgE3'></tfoot><dl id='DKgE3'><fieldset id='DKgE3'></fieldset></dl></div>
      1. 將對象的所有鍵轉換為小寫的最佳方法(最有效

        What#39;s the best way (most efficient) to turn all the keys of an object to lower case?(將對象的所有鍵轉換為小寫的最佳方法(最有效)是什么?)

          <bdo id='WHWSN'></bdo><ul id='WHWSN'></ul>
        • <small id='WHWSN'></small><noframes id='WHWSN'>

            <tbody id='WHWSN'></tbody>

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

                <tfoot id='WHWSN'></tfoot>
                  本文介紹了將對象的所有鍵轉換為小寫的最佳方法(最有效)是什么?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我想出了

                  function keysToLowerCase (obj) {
                    var keys = Object.keys(obj);
                    var n = keys.length;
                    while (n--) {
                      var key = keys[n]; // "cache" it, for less lookups to the array
                      if (key !== key.toLowerCase()) { // might already be in its lower case version
                          obj[key.toLowerCase()] = obj[key] // swap the value to a new lower case key
                          delete obj[key] // delete the old key
                      }
                    }
                    return (obj);
                  }
                  

                  但我不確定 v8 會如何處理它,例如,它真的會刪除其他鍵還是只會刪除引用而垃圾收集器稍后會咬我?

                  But I'm not sure how will v8 behave with that, for instance, will it really delete the other keys or will it only delete references and the garbage collector will bite me later ?

                  另外,我創建了 這些測試,希望您能添加你在那里的答案,這樣我們就可以看到它們是如何匹配的.

                  Also, I created these tests, I'm hoping you could add your answer there so we could see how they match up.

                  編輯 1:顯然,根據測試,如果我們不檢查密鑰是否已經是小寫字母,它會更快,但除了更快之外,它會因為忽略這一點而只創建新的小寫密鑰而造成更多混亂嗎?垃圾收集器會對此感到滿意嗎?

                  EDIT 1: Apparently, according to the tests, it's faster if we don't check if the key is already in lower case, but being faster aside, will it create more clutter by ignoring this and just creating new lower case keys ? Will the garbage collector be happy with this ?

                  推薦答案

                  最快的 我想如果你創建一個新對象:

                  The fastest I come up with is if you create a new object:

                  var key, keys = Object.keys(obj);
                  var n = keys.length;
                  var newobj={}
                  while (n--) {
                    key = keys[n];
                    newobj[key.toLowerCase()] = obj[key];
                  }
                  

                  我對 v8 的當前內部工作不夠熟悉,無法給你一個明確的答案.幾年前,我看到一個視頻,其中開發人員談論對象和 IIRC它只會刪除引用并讓垃圾收集器處理它.不過那是幾年前的事了,就算那時候是這樣,現在也不需要這樣了.

                  I'm not familiar enough with the current inner working of v8 to give you a definitive answer. A few years ago I saw a video where the developers talked about objects, and IIRC it will only delete the references and let the garbage collector take care of it. But it was years ago so even if it was like that then, it doesn't need to be like that now.

                  以后會咬你嗎?這取決于你在做什么,但可能不是.創建短期對象是很常見的,因此代碼經過優化以處理它.但是每個環境都有其局限性,也許它會咬你.您必須使用實際數據進行測試.

                  Will it bite you later? It depends on what you are doing, but probably not. It is very common to create short lived objects so the code is optimized to handle it. But every environment has its limitations, and maybe it will bite you. You have to test with actual data.

                  這篇關于將對象的所有鍵轉換為小寫的最佳方法(最有效)是什么?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                  JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發技術分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內容)
                  Restrictions of XMLHttpRequest#39;s getResponseHeader()?(XMLHttpRequest 的 getResponseHeader() 的限制?)
                  1. <legend id='lqDiA'><style id='lqDiA'><dir id='lqDiA'><q id='lqDiA'></q></dir></style></legend>
                    <i id='lqDiA'><tr id='lqDiA'><dt id='lqDiA'><q id='lqDiA'><span id='lqDiA'><b id='lqDiA'><form id='lqDiA'><ins id='lqDiA'></ins><ul id='lqDiA'></ul><sub id='lqDiA'></sub></form><legend id='lqDiA'></legend><bdo id='lqDiA'><pre id='lqDiA'><center id='lqDiA'></center></pre></bdo></b><th id='lqDiA'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='lqDiA'><tfoot id='lqDiA'></tfoot><dl id='lqDiA'><fieldset id='lqDiA'></fieldset></dl></div>

                          <tbody id='lqDiA'></tbody>

                        <tfoot id='lqDiA'></tfoot>

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

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

                            主站蜘蛛池模板: 国产精久久久 | 青青操av| 激情网五月天 | 尤物在线视频 | 国产一区中文 | 免费国产视频 | 国内久久 | 男女网站免费观看 | 亚洲视频一区二区三区 | 日韩精品一区二区三区在线 | 国产精品视频一区二区三区不卡 | 天天干天天色 | 精国产品一区二区三区四季综 | 欧美三区在线观看 | 亚洲男女视频在线观看 | 免费观看黄网站 | 精品一区二区三区视频在线观看 | 国产成人精品一区二区在线 | 人人爽日日躁夜夜躁尤物 | 欧美一级淫片007 | 国产一区欧美 | 久久综合婷婷 | 精品永久 | 亚洲成av人片在线观看无码 | 91精品国产综合久久精品图片 | 91久久精品日日躁夜夜躁欧美 | 国产欧美一区二区精品久导航 | 亚洲精品成人 | 精品国产一区二区在线 | 黑人成人网| 亚洲国产一区二区三区在线观看 | 亚洲久久| 日韩欧美在线视频 | 午夜精品一区二区三区在线视频 | 精品亚洲一区二区三区 | 亚洲一区二区在线 | 久久免费观看一级毛片 | www.伊人.com| 一级片免费在线观看 | 国产色爽 | 国产美女福利在线观看 |