loicdescotte
11/27/2014 - 4:52 PM

observe.js

var names = ['joe', 'bob'];

Object.observe(names, function(changes){
    changes.forEach(function(change) {        
      console.log(change.type, change.name)
    });
    console.log("names",names);
});


console.log("######## add loic");
names.push("loic");

console.log("names",names);

console.log("######## del bob");
names.splice(1,1);// output is "update 1 - delete 2", why?
console.log("names", names)