mirror of
https://github.com/wassname/Mostly-Harmless.git
synced 2026-06-27 16:10:28 +08:00
Added forEachIn utility
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user