Object.defineProperty相比Object.observe有什么优势
发布于 7 年前 作者 yakczh 3360 次浏览 来自 问答
var xx = {aa:100};

 
Object.observe(xx, function(changes){
console.log(changes);
    
    changes.forEach(function(change) {
   
        console.log(change.type, change.name, change.oldValue);
    });
});
xx.aa=200;
xx.oo=100;

Object.observe相比defineProperty能检测到新增,和删除 功能更强大,为什么反而取消了?

1 回复

也许和这个有关? https://github.com/tc39/proposal-observable 没仔细看过,不是很清楚。

回到顶部