zoukankan      html  css  js  c++  java
  • (三十一)设计模式之工厂模式

    function Animal(opts){
        var obj = new Object();
         obj.name = opts.name;
        obj.color = opts.color;
        obj.getInfo = function(){
             return '名称:'+obj.name +', 颜色:'+ obj.color;
         }
         return obj;
    }
    var cat = Animal({name: '波斯猫', color: '白色'}); cat.getInfo();
    

      

  • 相关阅读:
    day 01
    day14
    day12
    day13
    day11
    day9
    day10
    day08
    day07
    day06
  • 原文地址:https://www.cnblogs.com/bgwhite/p/9405776.html
Copyright © 2011-2022 走看看