对象的存储描述:
get 和 set 方法
<script>
var obj ={
get age(){
return 22
},
set age(value){
console.log(value)
}
}
console.log(obj.age)
obj.age = 23 var obj1 ={
x:1,
y:2,
z:3,
get zhouchang(){
return this.x+this.y+this.z
},
set two(value){
this.x*=value
this.y*=value
this.z*=value
}
}
console.log(obj1.zhouchang)
obj1.two =2
console.log(obj1.zhouchang) Object.defineProperty(obj1,"k",{
get : function(){
return 29
}
})
console.log(obj1.k)
</script>