console.log fallback (v2)

Revision 2 of this benchmark created on


Description

console.log fallback for IE

Test runner

Ready to run.

Testing in
TestOps/sec
for(i...) loop
if (typeof console === "undefined" || typeof console.log === "undefined") {
  var c = "assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(",");

  function emptyFunc() {}
  var console = {};
  for (var m = 0; m < c.length; m++) {
    console[m] = console[m] || emptyFunc;
  }
}
ready
forEach loop
if (typeof console.log == "object" && Function.prototype.bind && console) {
  function emptyFunc() {}
  var console = {},
    methods = ["assert", "count", "debug", "dir", "dirxml", "error", "exception", "group", "groupCollapsed", "groupEnd", "info", "log", "markTimeline", "profile", "profileEnd", "time", "timeEnd", "trace", "warn"];
  methods.forEach(function(m, index, theArray) {
    console[m] = console[] || emptyFunc;
  });
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published by console.log fallback on
  • Revision 2: published on