Created
June 26, 2013 19:45
-
-
Save grid23/5870941 to your computer and use it in GitHub Desktop.
Classic Object.keys polyfill with a twist: if an object instance of Arguments get into the function, old IEs will simply ignore the for ( k in arguments ) loop and the polyfill will silently fail... The *only way* to identify an object instance of Arguments in old IEs is to check for the presence of the method callee! If an arguments is detected…
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
| var enumerate = Object.keys || function(o){ | |
| var arr = [] | |
| , o = !!o.callee ? Array.prototype.slice.call(o) : o | |
| , k | |
| for ( k in o ) if ( arr.hasOwnProperty.call(o, k) ) | |
| arr.push(k) | |
| return arr | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment