son.js
function getInfo(num){
let buf = "title";
buf = buf.concat(" first");
buf = buf.concat(" second" + String(num));
return buf;
}
exports.getInfo = getInfo;
study.js
var son = require("./son");
function change() {
let count = 0;
setInterval(function () {
let text = son.getInfo(count++);
console.log(text);
}, 1000);
}
change();
结果:
$ node study.js
title first second0
title first second1
title first second2
title first second3