前端学习案例-你可能没见过的
原创
©著作权归作者所有:来自51CTO博客作者前端歌谣的原创作品,请联系作者获取转载授权,否则将追究法律责任
获取对象的属性
var obj={
get a(){
return Math.random()>=0.5?1:0
}
}
const round=obj.__lookupGetter__("a")
console.log(round)
//拿出 a(){
// return Math.random()>=0.5?1:0
// }
获取对象的属性
const round1=Object.getOwnPropertyDescriptors(obj,"a").get;
console.log(round)
//拿出 a(){
// return Math.random()>=0.5?1:0
// }
获取底层的属性
//底层拿的东西
obj.__defineGetter__("a",function(){
return "get a"
})