I am a bit confused with the code below, can we create class in js this way?
module.exports = function testname(paramas){
testname.test = function(req, res){
//some code here
}
return testname;
}
should not we use this.test instead of function name.test?
ClassName.methodnamecreates static members, whilethis.methodnamecreates instance membersIf you want to create some variables which should be encapsulated within the class objects when you create them, use
this.var.However, if you want a data member to be shared among all the instances of the same class then use
ClassName.var