From 48d0dbd179015efdf88dcd9858df2087a975d87c Mon Sep 17 00:00:00 2001 From: Kerrick Long Date: Tue, 28 Jun 2011 16:02:03 -0500 Subject: [PATCH] Added forEachIn utility --- js/common.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/js/common.js b/js/common.js index 2a46cfd..43555e5 100644 --- a/js/common.js +++ b/js/common.js @@ -35,6 +35,20 @@ MHUtils.prototype.epoch = function () { return Math.floor(new Date().getTime() / 1000); }; +/** + * Iterate over an object. + * @alias MHUtils.forEachIn(object, action) + * @return {Boolean} Returns true. + * @method + */ +MHUtils.prototype.forEachIn = function (object, action) { + for (var property in object) { + if (object.hasOwnProperty(property)) { + action(property, object[property]); + } + } +}; + /* * JavaScript Pretty Date * Thanks to Dean Landolt's comment on