js 2种不同的类的写法

// 对象1
var obj1 = {
    name: '四脚猫',
    _secret: '我的秘密',
    _toilet: function() { console.log(this.name + '上厕所ing') },
    _lave: function() { console.log(this.name + '洗澡ing') },
    show: function() {
        this._toilet()
        this._lave()
        console.log(this.name + ' hi')
    }
}


function make(name) {
    var secret = '我的秘密'
    var lave = function() { console.log(name + '洗澡ing') }
    var toilet = function() { console.log(name + '上厕所ing') }
    return {
        name: name,
        show: function() {
            toilet()
            lave()
            console.log(this.name + ' hi')
        }
    }
}
// 对象2
var obj2 = make('四脚猫升级版')
console.log(obj1, obj2)
tags: JavaScript