// foo.js
exports.foo = () => { ... };
// bar.js
exports.bar= () => { ... };
// foobar.js
exports.foobar= () => { ... };
<script>
var $ = require('jquery');
var foo = require('./js/foo');
var bar = require('./js/bar');
var foobar = require('./js/foobar');
</script>
// -- hello.js
module.exports.anything = function() {
console.log('I am anything.');
};
// -- hello-runner.js
const hello = require('./hello');
// let's see what's there in hello variable
console.log(hello); // {anything: Function}
hello.anything(); // I am anything.
// -- hello.js
exports.anything = function() {
console.log('I am anything.');
};
// -- hello-runner.js
const hello = require('./hello');
// let's see what's there in hello variable
console.log(hello); // {anything: Function}
hello.anything(); // I am anything.
exports는 module.exports 사용을 도와주는 helper
exports는 module.exports를 참조할 뿐이다.