diff options
author | portix <none@none> | 2012-06-24 23:31:47 +0200 |
---|---|---|
committer | portix <none@none> | 2012-06-24 23:31:47 +0200 |
commit | 934614002d1f5ef9b10c2b268d1f25d65d6eae70 (patch) | |
tree | 4391cb28584384f75a628128728b72d35c8bb6a6 /scripts | |
parent | 488f4f17703703c2603f658d3c5d2484fd512206 (diff) | |
download | dwb-934614002d1f5ef9b10c2b268d1f25d65d6eae70.zip |
Implementing forEach for javascript objects
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/util.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/scripts/lib/util.js b/scripts/lib/util.js index c51a5bc4..c6836f72 100644 --- a/scripts/lib/util.js +++ b/scripts/lib/util.js @@ -11,4 +11,14 @@ } }); Object.freeze(util); + if (Object.prototype.forEach === undefined) { + Object.defineProperty(Object.prototype, "forEach", { + value : function (callback) { + var key; + for (key in this) { + callback(key, this[key], this); + } + } + }); + } })(); |