SOURCE

var alertWindow = function(text) {
    this.content = text
    this.show = function() {
        window.alert(this.content)
    }
}

var aw = new alertWindow('test')
// console.log(aw.show())

var confirmWindow = function(text) {
    this.content = text
    this.show = function() {
        window.confirm(this.content)
    }
}

var cw = new confirmWindow('今天会下大雨?')
// cw.show()


var promptWindow = function(text) {
    this.content = text
    this.show = function() {
        window.prompt(this.content)
    }
}

var pw = new promptWindow('输入结束日期')
// pw.show()


var theWindow = function(type) {
    switch(type) {
        case "alert":
            return new alertWindow()
        case "confirm":
            return new confirmWindow()
        case "prompt": 
            return new promptWindow()
    }
}

const w = theWindow('alert')
w.content = '你好'
// w.show()


var thatWindow = function(type,text) {
    var o = new Object()
    o.content = text
    o.show = function() {
        if(type === 'alert') {
            window.alert(o.content)
        } else if(type === 'confirm') {
            window.confirm(o.content)
        } else if(type === 'prompt'){
            window.prompt(o.content)
        }
    }
    return o
}

const tw = thatWindow('confirm','这是一个简单工厂方法')
// tw.show()
console 命令行工具 X clear

                    
>
console