Skip to content

Instantly share code, notes, and snippets.

@pkrumins
Created July 11, 2010 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkrumins/471164 to your computer and use it in GitHub Desktop.
Save pkrumins/471164 to your computer and use it in GitHub Desktop.
// annoyingly many browsers don't have these:
if (!Object.keys) Object.keys = function (obj) {
var keys = [];
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
keys.push(key);
}
}
return keys;
};
if (!Array.prototype.forEach) Array.prototype.forEach = function (f) {
for (var i = 0; i < this.length; i++)
f(this[i]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment