类的调用:
Mail.js
function Mail(user_name,password){
this.user_name = user_name;
this.password = password;
}
Mail.prototype.autoRun = function() {
console.log(this.user_name+this.password);
};
module.exports = Mail;
main.js
const Mail = require('./Mail');
let mail = new Mail("123","abc");
mail.autoRun();
函数的调用:
Mail.js
var m= require('./formula');
var f = require('./function');
m.add(1,2);
f();
formula.js
function reduce(a,b){
console.log(a-b);
},
function add(a,b){
console.log(a+b);
}
module.exports = {
reduce,
add
}
function.js
module.exports = function print(){
console.log("我是fun3的方法");
}