Skip to content
Extends the JavaScript Object prototype to observe when an object is changed.
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
LICENSE
README.md initial release
bower.json
example.html
watch.js
watch.min.js

README.md

watch.js

Extends the JavaScript Object prototype to observe when an object is changed.

Usage is as follows:

var obj = {};

obj.watch(function(){
  // will be called when the object is modified
});

obj.unwatch(); // will stop watching for changes

In addition, two helper methods are added to the Object prototype: clone and isIdenticalTo.

Usage of these is as follows:

var obj1 = { alpha: "alpha", beta: "beta" };
var obj2 = obj1.clone(); // creates a clone of obj1

console.log( obj1 == obj2 ); // false because they are not the same object

console.log( obj1.isIdenticalTo(obj2) ); // true because they are identical

Have fun!

Something went wrong with that request. Please try again.