久久久久久久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在线 | 久久99深爱久久99精品 | 亚洲精品18| 久久久久久成人 | 亚洲国产一区二区视频 | 超碰97人人人人人蜜桃 | 欧美日韩国产三级 | 国产精品69毛片高清亚洲 | 国产成人精品亚洲日本在线观看 | 国产精品久久久久久久白浊 | 91日韩 | av在线一区二区 | 国产精品免费av | 99国产精品99久久久久久 | 毛片一区二区三区 | 请别相信他免费喜剧电影在线观看 | 成人在线视频一区 | 一本一道久久a久久精品综合蜜臀 | 欧美福利在线 | 日日夜夜天天 | www成人免费 | 欧美日韩国产一区二区三区 | 精品一区二区三区四区五区 | 久久久精品视频免费看 | 成人精品在线观看 | 狠狠艹 | 国产三级网站 | 久久久久中文字幕 | 国产午夜精品一区二区 | 亚洲精品乱码久久久久久蜜桃 | 在线观看中文字幕 | 国产在线精品一区二区 | 国产午夜精品久久久久免费视高清 | 日本电影网站 | 成人午夜精品 | 丝袜一区二区三区 | 99精品国自产在线 | 人人澡人人射 | 国产男女视频网站 |