Title says it all. What is the difference between simple module.exports and module.exports.run in javascript? I really couldn't find some info on the internet. Sorry.
module.exports
is kindof like an index of what's exported in your file.
For example, if file.js starts with the line module.exports = function(args) {
, when you import file.js using const file = require("./file.js")
you can access your function using file(arg1)
.
If file.js started with the line module.exports.run = function(args) {
however, if the file was imported the same way, you could only access your function using file.run()
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.