JS脚本可在 浏览器 和 NodeJS 中运行
浏览器
新建html文件
<!doctype html>
<html lang="en">
<head> <meta charset="UTF-8">
<title>Document</title>
</script> <script src="day05.js"></script>//引入js文件
</head>
<body>
</body>
</html>
新建js文件
console.log('hello world');
打开html,鼠标右键 或 F12进入开发者模式 单击console
结果显示

NodeJS
在命令行输入 node 进入NodeJS执行环境
结果显示

输入 console.log('hello world');
结果显示

网友评论