Created
January 29, 2013 17:42
-
-
Save nicjansma/4666076 to your computer and use it in GitHub Desktop.
Adds .apply() and .call() support to IE8/9's console object, which treates .log()/etc as Objects and not Functions. Requires jQuery for $.each().
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
if (Function.prototype.bind && typeof console == "object" && typeof console.log == "object") { | |
var logFns = ["log", "info", "warn", "error", "assert", "dir", "clear", "profile", "profileEnd"]; | |
$.each(logFns, function (i, method) { | |
console[method] = Function.prototype.call.bind(console[method], console); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requiring jquery just to iterate through the logFns array seems a bit overkill for projects, which do not use jquery. You could use:
for (var i = 0; i < logFns.length; i++) {
on line #4 and add an extra line after it:var method = logFns[i];
.