Created
January 21, 2010 18:47
-
-
Save sebmarkbage/283056 to your computer and use it in GitHub Desktop.
This file contains 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 dontEnum = ['toString', 'toLocaleString', 'valueOf', 'toSource', 'watch', 'unwatch', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable']; | |
var failsEnumTest = (function(){ | |
for (var k in { toString: {} }) return false; | |
return true; | |
})(); | |
Object.each = function(obj, fn){ | |
for (var key in obj) fn(obj[key], key); | |
if (failsEnumTest) | |
for (var i=0,l=dontEnum.length;i<l;i++){ | |
var key = dontEnum[i], value = obj[key]; | |
if (value !== Object.prototype[key]) fn(value, key); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment