nodejs自学.js

function hello(){
console.log("hello world");
}

function s(){
console.log("this is a ew");
}

function add(a, b){
return a+b;
}

exports.hello = hello;//留出接口
exports.s = s;
exports.add = add;

test.js

//加载模块
var app = require("./nodejs自学");//./表示当前目录,也可以填"./nodejs自学.js"
app.hello();
app.s();
console.log(app.add(1,3));

 

在终端中 node test.js 

结果:

hello world

this is a ew

4

相关文章:

  • 2022-12-23
  • 2021-09-06
  • 2021-12-14
  • 2021-06-13
  • 2021-05-28
  • 2022-01-25
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-14
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案