Skip to content

Instantly share code, notes, and snippets.

@grid23
Created June 26, 2013 19:45
Show Gist options
  • Select an option

  • Save grid23/5870941 to your computer and use it in GitHub Desktop.

Select an option

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…
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