码迷,mamicode.com
首页 > 其他好文 > 详细

工厂函数批量创建对象

时间:2020-05-16 12:44:42      阅读:65      评论:0      收藏:0      [点我收藏+]

标签:批量   this   ons   div   func   his   des   fun   var   

   function Person(name,age,desc) {
      var obj = {
        name: name,
        age: age,
        desc: desc,
        say: function () {
          console.log(‘大家吼,我系‘ + this.name)
        }
      }
      return obj;
    }

    var xm = Person(‘小明‘,  18, ‘好看‘);
    var xl = Person(‘小丽‘, 20, ‘美丽‘)

工厂函数批量创建对象

标签:批量   this   ons   div   func   his   des   fun   var   

原文地址:https://www.cnblogs.com/xiaoxiao95/p/12899633.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!