javascript创建对象之动态原型模式(五)

 1 function Human(name, sex) {
 2             this.name = name;
 3             this.sex = sex;
 4             if (typeof this.say != "function") {
 5                 Human.prototype.say = function () {
 6                     alert(this.name);
 7                 }
 8             }
 9         }
10         var man =new Human ("凯撒", "男");
11         man.say();
原文地址:https://www.cnblogs.com/guoyansi19900907/p/3624758.html