<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script type="text/javascript">
//定义多个属性
//Object.defineProperties
var book = {}
Object.defineProperties(book , {
_year: {
value: 2004
},
edition:{
value: 1
},
year: {
get: function(){
return this._year;
},
set: function(newValue){
if(newValue > 2004){
this._year = newValue;
this.edition += newValue - 2004;
}
}
}
})
</script>
</body>
</html>