码迷,mamicode.com
首页 > Web开发 > 详细

js匿名函数封装

时间:2018-12-06 10:20:05      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:factory   class   root   object   define   ports   port   exp   init   

js匿名函数封装

(function(root,factory){
    typeof exports === ‘object‘ && typeof module !== ‘undefined‘ ? module.exports = factory() :
    typeof define === ‘function‘ && define.amd ? define(factory) :
    (root.Demo = factory());
})(this,function(){
    function Demo(option){
        this._init(option)
    }
    Demo.prototype = {
        constructors: Demo,
        _init:function(option){
            this.name = option.name;
            this.age = option.age;
        }
    }
    return Demo;
});

 

js匿名函数封装

标签:factory   class   root   object   define   ports   port   exp   init   

原文地址:https://www.cnblogs.com/chachanode/p/10074716.html

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