Skip to content

Instantly share code, notes, and snippets.

@hamburgerwang
hamburgerwang / object-watch.js
Created January 4, 2012 00:36 — forked from eligrey/object-watch.js
object.watch polyfill
// Cross-browser object.watch and object.unwatch
// object.watch
if (!Object.prototype.watch) {
Object.prototype.watch = function (prop, handler) {
var oldval = this[prop], newval = oldval,
getter = function () {
return newval;
},
setter = function (val) {