Last Updated: February 25, 2016
·
1.142K
· lperrin

Find when an object is modified in JavaScript

There's an object in your js app that is mysteriously updated. Your app deals with lots of real time events and you don't know where to start. Object.observe is the solution.

Object.observe is part of ES6 and is notably implemented by Chrome. The cool thing is that you can use it on-the-fly, without having to change your code.

Just open the js console and break somewhere where you object is in scope, before the unexpected change occurs. Then, just type:

Object.observe(myObj, function () {
  debugger;
});

Then, do the action that triggers the unexpected change and look in the call stack for your code.