1、demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JS DEBUG</title>
</head>
<body>
<h1>JS DEBUG</h1>
<script>
let fn = function (x) {
let num = 2;
return num + x;
};
alert(fn(2));
</script>
</body>
</html>
2、source面板
command+option +i 打开devtools
3、调试方法
3.1 console.log
3.2 断点调试
可以点击代码编辑窗口的代码行手动打断点,也可以根据勾选事件类型打断点。
3.3 进入函数
可以通过点击如下按钮进入函数调试