const user={
    // name:"hundsun",
    // age:16
    data:{name:"yss",age:12},
    list:[
        {price:12},
        {price:12},
        {price:13}

    ],
    //访问其伪造属性操作
    get total(){
        return this.list.reduce((t,l)=>{
           return t+l.price
        },0);
    }
}

user.age=13;
console.log(user.total);

 

posted on 2022-01-23 14:49  weakup  阅读(13)  评论(0编辑  收藏  举报