Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript两个快速调试的技巧 #72

Open
reng99 opened this issue Sep 24, 2020 · 0 comments
Open

JavaScript两个快速调试的技巧 #72

reng99 opened this issue Sep 24, 2020 · 0 comments
Labels
blog a single blog javascript javascript tag

Comments

@reng99
Copy link
Owner

reng99 commented Sep 24, 2020

直接上干货!💨

console.table展示数据

在控制台上展示数组或对象,使用console.tableconsole.log更加直观明了。

// 在控制台上运行
console.table([
  { firstName: 'John', lastName: 'Doe', age: 2 },
  { firstName: 'William', lastName: 'Shakespeare', age: 3 }
])

展示为一个table表,友好很多:
table

当然,你还可以指定展示哪些列~

// 在控制台上运行
console.table([
  { firstName: 'John', lastName: 'Doe', age: 2 },
  { firstName: 'William', lastName: 'Shakespeare', age: 3 }
], ['firstName', 'lastName'])

上面指定展示firstNamelastName这两列,当然,(index)
是默认有的。

table_column_option

注意⚠:语法 console.table(data [, columns]);

copy复制数据

如果你使用谷歌浏览器并需要复制控制台输出的数据。你可以使用copy()命令行,而不是手动高亮选择对应代码进行复制。

const data = [2, 3, 4];
copy(data);

执行上面的代码,会将data数据值复制到你的粘贴板上。你可以在任意文档中进行粘贴。

注意⚠:copy命令仅在谷歌浏览器控制台上生效,并且在node.js环境中无效。

参考

@reng99 reng99 added blog a single blog javascript javascript tag labels Sep 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blog a single blog javascript javascript tag
Projects
None yet
Development

No branches or pull requests

1 participant