[JavaScript] JavaScript中面向对象的实现动态原型模式 →→→→→进入此内容的聊天室

来自 , 2020-09-28, 写在 JavaScript, 查看 167 次.
URL http://www.code666.cn/view/c2073ffa
  1. //动态原型模式
  2.         function Person(name, age, job) {
  3.             this.name = name;
  4.             this.age = age;
  5.             this.job = job;
  6.             if(typeof this.sayName!="function") {
  7.                 this.sayName = function () {
  8.                     alert(this.name);
  9.                 };  
  10.             }
  11.             if(typeof this.sayInfo!="function") {
  12.                 this.sayInfo = function() {
  13.                     console.log(this.job);
  14.                 };
  15.             }
  16.         }
  17. //javascript/6976

回复 "JavaScript中面向对象的实现动态原型模式"

这儿你可以回复上面这条便签

captcha