Wednesday, 28 December 2016

node.js - Function Overloading on prototype Javascript?

I wanted to know if we can overload a function on prototype object in JavaScript?



function Person(name, family) {
this.name = name;
this.family = family;
}

Person.prototype.getFull = function() {

return this.name + " " + this.family;
};

Person.prototype.getFull = function(someParam) {
return this.name + " " + this.family;
};


var p = new Person();
p.getFull();

p.getFull(someparam);

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...