Reputation: 409
I have the following code:
module.exports.functionA = function(str) {
console.log(str);
}
In the same module, how do I call functionA? In other languages such as PHP, you can call another member of the same class using $this->functionA();
This does not work:
module.exports.functionA('Hello world!');
Upvotes: 0
Views: 723
Reputation: 409
When functionA
was assigned to module.exports it was still undefined. Instead do:
var functionA = function(str) {
console.log(str);
}
module.exports = {
functionA: functionA
}
Then the following will work:
module.exports.functionB = function() {
functionA('Hello world!');
}
Upvotes: 4