MDGSF Software Engineer

[Web] javascript module

2018-07-06
mdgsf
Web

在同一个目录下建立 hello.js 和 main.js

hello.js

'use strict';

var s = 'Hello';

function greet(name) {
    console.log(s + ', ' + name + '!');
}

module.exports = greet;

main.js

'use strict';

var greet = require('./hello');

var s = 'Michael';

greet(s);

https://www.liaoxuefeng.com/wiki/001434446689867b27157e896e74d51a89c25cc8b43bdb3000/001434502419592fd80bbb0613a42118ccab9435af408fd000


weixingongzhonghao

Comments

Content