如何用node执行js代码
以前没怎么写过前端代码,一直以为,写前端代码需要在浏览器里面执行,打开控制台,然后debug之类的。
首先写一段js的代码
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23// 类 class Animal{ constructor(name) { this.name = name } run() { return `${this.name} is running` } } const snake = new Animal('lily') console.log(snake.run()) class Dog extends Animal{ bark(){ return `${this.name} is barking` } } const xiaobao = new Dog('xiaobao') console.log(xiaobao.run()) console.log(xiaobao.bark())
进入cmd窗口,执行命令node class.js
复制代码
1
2
3
4
5c>node class.js lily is running xiaobao is running xiaobao is barking
最后
以上就是贪玩香水最近收集整理的关于如何用node执行js代码如何用node执行js代码的全部内容,更多相关如何用node执行js代码如何用node执行js代码内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复