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

console.log 中的錯誤?

Bug in console.log?(console.log 中的錯誤?)
本文介紹了console.log 中的錯誤?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

可能重復:
Chrome 的 JavaScript 控制臺是否懶于評估數組?

我嘗試以下代碼:

var myList = new Object();
var item   = new Object();
item.text  = "item-1";
myList[3]  = item;

console.log(myList);
console.log(myList[3].text);

// Assign another object to the same entry
var item2   = new Object();
item2.text  = "item-2";
myList[3]  = item2;

console.log(myList);
console.log(myList[3].text);

結果很奇怪:

* Object
  * 3: Object
      text: "item-2"

item-1

* Object
  * 3: Object
      text: "item-2"

item-2

但是 - 如果我在一段時間后執行第二部分(使用 setTimeout)并展開第一個對象,我做對了,即:

BUT - if i execute the second part after some time (using setTimeout), and unfold the first object, I get it right, i.e.:

* Object
  * 3: Object
      text: "item-1"

item-1

* Object
  * 3: Object
      text: "item-2"

item-2

我覺得分享它很重要,因為我認為人們可能會浪費大量時間來嘗試理解他的代碼中的問題.如果有人提到了一個開放的錯誤或其他東西 - 請回復這張票.謝謝!

I find it important to share it, since I think one can waste a lot of time trying to understand what's wrong in his code. And if somebody has some reference to an open bug or something - please reply this ticket. Thanks!

推薦答案

我的觀點是,這是一個非常煩人的功能",我真的希望我可以關閉它,它使調試成為一場噩夢,不知道在什么時候時間可能已經更新了一個對象,同時試圖在代碼中的給定點建立精確的對象狀態.該功能可能對觀察點"等有用,但不適用于所謂的日志"(線索就在名稱中).

My view is that this is a horrendously irritating 'feature' that I really wish I could turn off, it makes debugging a nightmare, not knowing at which point in time something may have updated an object, whilst trying to establish exact object state at a give point in the code. The feature could be useful for 'watch points' etc, but not in something called a 'LOG' (the clue is in the name).

考慮這個代碼片段:

var person = {'name':'Tom'};
console.log( person);  //output the entire object variable
person.name = 'Thomas';
//the output is an object, whose 'name' value is 'Thomas', even though the log statement was placed before the value was changed to 'Thomas'.

然后:

var person = {'name':'Tom'};
console.log( person.name);    //changed to output a string variable
person.name = 'Thomas';
//the output here, however, has not dynamically updated and correctly outputs 'Tom'

這篇關于console.log 中的錯誤?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 久久久久国产精品免费免费搜索 | 成人精品国产免费网站 | 欧美a在线 | 久久久蜜臀国产一区二区 | 亚洲一区二区三区视频在线 | 精品国产黄a∨片高清在线 成人区精品一区二区婷婷 日本一区二区视频 | 日本一级淫片免费啪啪3 | av性色全交蜜桃成熟时 | 国产精品久久国产精品久久 | 日日摸夜夜添夜夜添精品视频 | 精品一区二区久久 | 日韩欧美一区二区三区免费观看 | 国产一区二区三区色淫影院 | 成人精品 | 亚洲日本中文字幕在线 | 爽爽免费视频 | 国产精品久久久一区二区三区 | 在线观看国产精品一区二区 | yeyeav | 亚洲精品黄 | 亚洲精品乱码 | 一级毛片大全免费播放 | 国产精品日韩欧美一区二区三区 | 一区二区三区国产 | 成人妇女免费播放久久久 | 欧美视频在线观看 | 国产成人99久久亚洲综合精品 | 午夜免费电影 | 在线观看中文视频 | 亚洲精品久久久久中文字幕欢迎你 | 亚洲精品一区在线观看 | 日韩高清中文字幕 | 欧美亚洲国产一区二区三区 | 成人免费久久 | 怡红院成人在线视频 | 亚洲日本欧美 | 亚洲网站在线 | 视频一区二区在线观看 | 日韩一区二区三区在线视频 | 中文字幕在线免费 | 蜜桃视频在线观看免费视频网站www |