20 lines
640 B
Markdown
20 lines
640 B
Markdown
---
|
||
title: Use the JavaScript Console
|
||
localeTitle: 使用JavaScript控制台
|
||
---
|
||
Chrome和Firefox都有出色的JavaScript控制台,也称为DevTools,用于调试JavaScript。
|
||
|
||
您可以在Chrome的菜单或FireFox菜单中的Web控制台中找到开发人员工具。如果您使用的是其他浏览器或手机,我们强烈建议您使用桌面版Firefox或Chrome。
|
||
|
||
您还可以使用[https://repl.it/](https://repl.it/)在线运行代码。
|
||
|
||
这是您打印到控制台的方式:
|
||
```
|
||
console.log('Hello world!')
|
||
```
|
||
|
||
您还可以使用以下代码在控制台中打印错误日志:
|
||
```
|
||
console.error('I am an error!')
|
||
|
||
``` |