Created
March 4, 2011 22:29
-
-
Save revolunet/855824 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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