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.
Written by Laurent Perrin
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Debugger
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#