JavaScript 数组 `console.log` 输出行为

标签 javascript console console.log

当我们在数组上运行 forEach() 函数时,根据 indexitems 的排列方式,开发工具会返回不同的输出。我想知道是否有人知道为什么会发生这种情况。

请看下面的图片:

enter image description here

当我将变量从 item, index 交换到 index, item 时,输出看起来不同。

enter image description here

我想知道是什么使变量输出不同以及为什么。

最佳答案

根据有关 console.log 的 MDN 文档 here

这解释了第一个参数被处理为对象或字符串。后续参数将作为对象处理。

假设这会强制从第二个参数开始的字符串使用引号进行打印。

要了解有关 chrome 控制台的更多信息,请访问 this page

关于JavaScript 数组 `console.log` 输出行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44879547/

相关文章:

c# - MySql.Data.MySqlClient C# 控制台应用程序

polymer - 修复不赞成使用的文件

javascript - Cookie 的其他替代品

javascript - 避免回调 hell 。 Meteor.call promise

linux - Telnet : How to remove NULL (0x00) after every CR (0x0d) on send, using char mode (interactive mode)?

javascript - 这个 setTimeout 是如何工作的?什么是 49221 以及 console.log.bind 是如何工作的?

javascript - 如何默默地记录东西而不干扰正常开发,直到我需要它

javascript - 如何检测后退按钮和新窗口?

javascript - div mouseenter 显示并保持焦点

c++ - 异步输入输出/获取前缀后的输入