Is there any convention to where we should declare the module.exports
no Javascript/Node.js module files?
Should it be in the beginning of the file like:
module.exports = Foo;
function Foo() {
this.bar = 'bar';
}
Foo.prototype.getBar = function() {
return this.bar;
}
Or should it be in the end of the file:
function Foo() {
this.bar = 'bar';
}
Foo.prototype.getBar = function() {
return this.bar;
}
module.exports = Foo;
I know that there is no technical difference. The first example is perfectly valid because of declaration hoisting.
So I was wondering if there are some kind of best practices.