函数重载原型Javascript?

时间:2017-10-09 13:56:14

标签: javascript node.js prototype

我想知道我们是否可以在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);

0 个答案:

没有答案