SOURCE

var CreateDiv = function (html) {
    this.html = html
    this.init()
}

CreateDiv.prototype.init = function () {
    var div = document.createElement('div')
    div.innerHTML = this.html
    document.body.appendChild(div)
}

var ProxySingletonCreateDiv = (function() {
    var instance
    return function (html) {
        if (!instance) {
            instance = new CreateDiv(html)
        }

        return instance
    }
})()

var a = new ProxySingletonCreateDiv('sven1')
var b = new ProxySingletonCreateDiv('sven2')

console.log(a === b)
// 有问题,应该把创建的 div 绑定到实例上,具体就不多改了
console 命令行工具 X clear

                    
>
console