Skip to content

Instantly share code, notes, and snippets.

@revolunet
Created March 4, 2011 22:29
Show Gist options
  • Select an option

  • Save revolunet/855824 to your computer and use it in GitHub Desktop.

Select an option

Save revolunet/855824 to your computer and use it in GitHub Desktop.
// javascript objects keys method
// from http://javascriptweblog.wordpress.com/2011/02/28/javascript-object-keys-finally/
//all browsers
if (typeof Object.keys != 'function') {
Object.keys = function(obj) {
if (typeof obj != "object" && typeof obj != "function" || obj == null) {
throw TypeError("Object.keys called on non-object");
}
var keys = [];
for (var p in obj) obj.hasOwnProperty(p) &&keys.push(p);
return keys;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment