zoukankan      html  css  js  c++  java
  • 简单的单体??

    <script>
    var singleton = function() {
        var uniqueInstance;
        function constructor() {
            var id = '1';
            function add() {
                return id + '2';
            };

            function add1() {
                return '3';
            };

            return {
                name : 'name',
                method : function() {
                    alert(this.name + add() + add1());
                }
            }
        }

        return {
            getInstance : function() {
                if(!uniqueInstance) {
                    uniqueInstance = constructor();
                }
                return uniqueInstance;
            }
        }
    }();

    singleton.getInstance().method();
    </script>
    《javaScript设计模式》第五章观后感
  • 相关阅读:
    爬虫-requests-html
    pillow
    bs4-mysql-豌豆荚
    代理池-豆瓣电影
    Codeforces 1373D
    Codeforces 1365D
    AtCoder "NOMURA Programming Competition 2020" C
    Codeforces 1359D
    Codeforces 1359C
    Codeforces 1358D
  • 原文地址:https://www.cnblogs.com/maxfong/p/2374991.html
Copyright © 2011-2022 走看看