久久久久久久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?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 久久久久久999 | 精品一区二区三区中文字幕 | 在线视频一区二区三区 | 国产精品69久久久久水密桃 | www.色综合 | 国产高清在线 | 手机av在线 | 国产乱码精品一区二区三区忘忧草 | 久久综合久 | 婷婷在线网站 | 天天综合国产 | 亚洲国产二区 | 色综合色综合色综合 | 精品福利一区二区三区 | 国产一区精品在线 | 国产精品视频久久 | 免费在线h视频 | 久久国产精品99久久久久 | 91久久久精品国产一区二区蜜臀 | 精品中文字幕在线 | 国产91 在线播放 | 精品国产乱码久久久久久中文 | jav成人av免费播放 | 精品国产精品三级精品av网址 | 亚洲欧洲一区二区 | 欧美精品欧美精品系列 | 亚洲欧美中文字幕 | 免费人成在线观看网站 | 国产亚洲精品综合一区 | 婷婷在线网站 | 亚洲国产精品成人久久久 | 最新超碰| 亚洲三区在线播放 | h视频免费观看 | 日韩淫片免费看 | 日本特黄特色aaa大片免费 | 欧美v日韩v | 一区欧美 | 久久久久国产精品一区三寸 | 久久国产亚洲 | 我要看黄色录像一级片 |