Discuss / JavaScript / 练习

练习

Topic source

hello.js内容如下

'use strict'

var s = 'Hello'

function hello(name) {

  console.log(s + ', ' + name + '!')

}

function hi(name) {

  console.log(s + ', ' + name + '!')

}

module.exports = {

  hello: function(name) {

    return hello(name)

  },

  hi: function(name) {

    return hi(name)

  }

}

main.js内容如下

'use strict'

// 引入hello模块:

var hello = require('./hello')

var s = 'Michael'

hello.hello(s)

hello.hi(s)


  • 1

Reply