属性设置器 #

var document = {};
//添加属性
Object.defineProperty(document, 'cookies', {
    value:[]
})

//添加访问器属性
Object.defineProperty(document, 'cookie', {
    set :function(cookie){
        this.cookies.push(cookie);
    },
    get :function(){
        return this.cookies.join('; ');
    }
})


document.cookie = 'name=zfpx';
document.cookie = 'age=6';
console.log(document.cookie);