0
点赞
收藏
分享

微信扫一扫

js 题

兵部尚输 2022-11-05 阅读 140

 

 

 

var a = {
n:1,
valueOf:function(){
return this.n++;
}
};


console.log(
a == 1 &&
a == 2 &&
a == 3
);

 

 

var o = (function(){
var obj = {
a:1,
b:2,
};
return {
get :function(k){
return obj[k];
}
};
})();
//在不修改上面的代码的情况下, 修改obj
Object.defineProperty(Object.prototype,'abc',{
get(){
return this;
}
});


console.log(o.get('abc'));

 



举报

相关推荐

0 条评论