javascripteventsobjectdetectwatch

Detecting change in a Javascript Object


I found this gist to detect changes on specified fiels of a object : https://gist.github.com/3138469

But it bind an event only on one field.

Someone know a function or a tricks to detect change on an entire Javascript Object ?


Solution

  • 2019 Update: These days this can be achieved using Proxy API in a much more efficient manner. The on-change library uses the Proxy API behind the scene to make this even easier.

    2012 Update: I've just noticed that the author of Watch.js is referencing a library with much broader browsers' support. MultiGetSet.JS

    When I want to achieve this I usually use Watch.js, you can watch a whole object or one attribute.