Students must be called as a constructor .
var s = new Students(); s.add()
Inside Students , this will be a new object that inherits from Prorotype students and automatically returns. Therefore, speaking
this.add = function() ....
adds the add function to this object, which is returned. But the function will be created de novo every time this function is called. Why not add it to the prototype instead, so the function will exist only once , and will not necessarily be re-created each time.
Students.prototype.add = function(){
source share