Quantcast
Channel: CNode:Node.js专业中文社区
Viewing all articles
Browse latest Browse all 14821

Object.defineProperty相比Object.observe有什么优势

$
0
0
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能检测到新增,和删除 功能更强大,为什么反而取消了?


Viewing all articles
Browse latest Browse all 14821

Trending Articles