Supposed I have the following exports
function inside validate.js
of my Node.Js app:
exports.stopwordsClean = function () {
return function(req, res, next){
console.log("validating...");
}
};
I understand that to refer to this function from another file I would first require
this file and then use validate.stopwordsClean()
But how do I refer to it from inside the same file? this.stopwordsClean()
doesn't work...
exports
is an object which is available in module
. When you write exports.stopwordsClean = function () {..
you are setting a property stopwordsClean
of exports
object. Therefore you can always use
exports.stopwordsClean()
to use the function inside the same module.
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.