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

谷歌瀏覽器 console.log 亂序?

Google Chrome console.log out of sequence?(谷歌瀏覽器 console.log 亂序?)
本文介紹了谷歌瀏覽器 console.log 亂序?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

有人可以解釋以下兩個(gè)輸出嗎?

Can someone explain the following two outputs?

代碼 1:

console.log(itemsAry);
//loadNextItem();
function loadNextItem(){
    var item = itemsAry.shift();
    console.log(item);
}

結(jié)果:

["cat-53", "cat-57", "cat-51", "cat-10", "cat-55", "cat-56", "cat-5", "cat-50", "cat-3", "cat-54", "cat-52", "cat-9", "cat-8", "cat-4", "cat-58", "cat-6", "cat-7"]

(如預(yù)期).

代碼 2:

console.log(itemsAry);
loadNextItem();
function loadNextItem(){
    var item = itemsAry.shift();
    console.log(item);
}

結(jié)果:

["cat-57", "cat-51", "cat-10", "cat-55", "cat-56", "cat-5", "cat-50", "cat-3", "cat-54", "cat-52", "cat-9", "cat-8", "cat-4", "cat-58", "cat-6", "cat-7"]

cat-53

請(qǐng)注意,cat-53 已從原始數(shù)組 PRIOR 轉(zhuǎn)移到 console.log() 輸出,該輸出應(yīng)該在 shift 操作之前發(fā)生地方.我怎么可能?或者我錯(cuò)過了什么?

Notice that cat-53 has been shifted from the original array PRIOR to the console.log() output that is supposed to be occurring BEFORE the shift operation ever takes place. How i this possible? Or what am I missing?

情況變得更糟:

console.log(itemsAry);
loadNextItem(); loadNextItem(); loadNextItem(); loadNextItem();
function loadNextItem(){
    var item = itemsAry.shift();
    console.log(item);
    console.log(itemsAry);
}

結(jié)果:

["cat-55", "cat-56", "cat-5", "cat-50", "cat-3", "cat-54", "cat-52", "cat-9", "cat-8", "cat-4", "cat-58", "cat-6", "cat-7"]
cat-53
["cat-55", "cat-56", "cat-5", "cat-50", "cat-3", "cat-54", "cat-52", "cat-9", "cat-8", "cat-4", "cat-58", "cat-6", "cat-7"]
cat-57
["cat-55", "cat-56", "cat-5", "cat-50", "cat-3", "cat-54", "cat-52", "cat-9", "cat-8", "cat-4", "cat-58", "cat-6", "cat-7"]
cat-51
["cat-55", "cat-56", "cat-5", "cat-50", "cat-3", "cat-54", "cat-52", "cat-9", "cat-8", "cat-4", "cat-58", "cat-6", "cat-7"]
cat-10

在 FireFox 中進(jìn)行測(cè)試后,這似乎是特定于 Google Chrome 的問題.FF 輸出:

After testing in FireFox, it appears to be a Google Chrome issue specifically. FF output:

["cat-53", "cat-57", "cat-51", "cat-10", "cat-55", "cat-56", "cat-5", "cat-50", "cat-3", "cat-54", "cat-52", "cat-9", "cat-8", "cat-4", "cat-58", "cat-6", "cat-7"]
cat-53
["cat-57", "cat-51", "cat-10", "cat-55", "cat-56", "cat-5", "cat-50", "cat-3", "cat-54", "cat-52", "cat-9", "cat-8", "cat-4", "cat-58", "cat-6", "cat-7"]
cat-57
["cat-51", "cat-10", "cat-55", "cat-56", "cat-5", "cat-50", "cat-3", "cat-54", "cat-52", "cat-9", "cat-8", "cat-4", "cat-58", "cat-6", "cat-7"]
cat-51
["cat-10", "cat-55", "cat-56", "cat-5", "cat-50", "cat-3", "cat-54", "cat-52", "cat-9", "cat-8", "cat-4", "cat-58", "cat-6", "cat-7"]
cat-10
["cat-55", "cat-56", "cat-5", "cat-50", "cat-3", "cat-54", "cat-52", "cat-9", "cat-8", "cat-4", "cat-58", "cat-6", "cat-7"]

按預(yù)期輸出...

推薦答案

console.log 總是有點(diǎn)遲到",當(dāng)涉及到對(duì)象時(shí),你不能指望它.只有原語(字符串等)才能直接工作.前者在內(nèi)存中只有一個(gè)實(shí)例,所以當(dāng)控制臺(tái)獲取數(shù)據(jù)時(shí),它可能已經(jīng)改變了.

console.log is always a little "late" and you can't count on it when it comes to objects. Only primitives (strings etc.) will work directly. Of the former there is only one instance in memory, so when the console is fetching the data it may have changed already.

當(dāng)然,這取決于您實(shí)際使用的控制臺(tái),但我經(jīng)常在 Chrome 上遇到這種情況.

Of course, it depends on which console you're actually using, but I'm frequently experiencing this on Chrome.

這里有人在螢火蟲.

這篇關(guān)于谷歌瀏覽器 console.log 亂序?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進(jìn)程中創(chuàng)建子窗口時(shí)如何修復(fù) BrowserWindow 不是構(gòu)造函數(shù)錯(cuò)誤) - IT屋-程序員軟件開發(fā)技術(shù)
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應(yīng)用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個(gè) loadURL 上執(zhí)行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內(nèi)使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲(chǔ)?)
How to access camera/webcamera inside electron app?(如何在電子應(yīng)用程序中訪問相機(jī)/網(wǎng)絡(luò)攝像頭?)
主站蜘蛛池模板: 国产精品伦理一区二区三区 | 九九综合九九 | 国产精品美女久久久久久久网站 | 国产精品自拍啪啪 | 欧美一区二 | 日韩一二区在线 | 国产不卡在线观看 | 久久久免费精品 | 国产欧美精品一区二区三区 | 国产精品福利在线 | 久久亚洲综合 | 亚洲日本国产 | 国产精品一区二区福利视频 | 欧美国产精品 | 九九免费在线视频 | 亚洲欧美在线视频 | 夜夜艹| 日韩免费视频一区二区 | 亚洲日日 | 热久色| a视频在线| 久久久在线视频 | 国产美女在线免费观看 | 日韩成人免费视频 | 91视频正在播放 | 狠狠色综合久久婷婷 | 免费三级黄 | 欧美日韩成人网 | 四虎av电影| 国产一区二区三区免费 | 99中文字幕 | 狠狠躁夜夜躁人人爽天天高潮 | 亚洲综合色网站 | 男女羞羞视频在线 | 亚洲精品免费视频 | 国产中文字幕在线观看 | 久草热在线 | 精品美女视频在免费观看 | 久久精品一级 | 日韩欧美一级精品久久 | 成人免费xxxxx在线视频 |