console.dir()和dir()

本文深入解析了Console API中的dir()方法,该方法用于在控制台中以交互方式展示指定JavaScript对象的所有属性。通过使用dir(),开发者可以清晰地查看对象属性,便于理解和调试。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

来自MDN的定义

The Console method dir() displays an interactive list of the properties of the specified JavaScript object. The output is presented as a hierarchical listing with disclosure triangles that let you see the contents of child objects.

In other words, console.dir() is the way to see all the properties of
a specified JavaScript object in console by which the developer can
easily get the properties of the object.

通过它,我们可以看到一个节点对象的全部属性。
在这里插入图片描述
其实dir()也一样
在这里插入图片描述
在别的文档中,我也有反复看到

dir(object) 显示所有指定对象的属性的对象样式列表。此方法等同于 Console API 的 console.dir() 方法。

dir(object) 将指定对象的所有属性显示为对象样式的列表。 此方法是Console API的console.dir()方法的别名。

不过
在这里插入图片描述
真是让人头大。。。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值