man.age赋值为100后为什么输出的age也是100,val = +val是什么意思,不是等于val = val + val 吗
var man = {
weibo:'@Bosn',
$age:null,
get age(){
if(this.$age== undefined){
return new Date().getFullYear() - 1986;
}else{
return this.$age;
}
},
set age(val){
val = +val;
if(!isNaN(val) && val > 0 && val < 150){
this.$age = +val;
}else{
throw new Error('Incorrect val =' + val);
}
}
}
console.log(man.age);