News for hackers. Stuff that matters.
Re:Firebug lead developer now working on Web dev tools at Go... by enneff on Sunday July 17, 2011 @07:09PM (#2774474)
if (!window.console) { window.console = { log: function() {} } }
Re:Firebug lead developer now working on Web dev tools at Go... by Inviz on Sunday July 17, 2011 @08:42PM (#2774671)
1. there are more methods (dir, group, error, etc)

2. some browsers provide console.log but not others

3. those methods most of the time are not .apply'able or .call'able. that matters when you try to output an array of items with the right firebug/devtools coloring. But you cant. You get the ["Message", "was sent", {Object}] output with the arrayish square brackets and all strings with the double quotes. If you pass values directly via console.log(type, action, object) the output will not have double quotes around each string and the "Message was sent" part will read as one sentence, not two values of one array.

4. Some combinations of firefox (i think ff4) with firebug (even disabled) raise exceptions when you attempt to redefine one of the console objects. The exception alone renders some of the sites broken.

Handling the console object is needlessly painful and hard. Someone has to stop it.

Re:Firebug lead developer now working on Web dev tools at Go... by psadauskas on Sunday July 17, 2011 @10:28PM (#2774885)

    function myLog() {
      if(window.console && window.console.log) {
        window.console.log(arguments)
      }
    }
Re:Firebug lead developer now working on Web dev tools at Go... by Inviz on Sunday July 17, 2011 @10:46PM (#2774920)
What do you think happens when you pass arguments to functions like that?
Re:Firebug lead developer now working on Web dev tools at Go... by jdunck on Sunday July 17, 2011 @11:39PM (#2775026)
window.console.log.apply(window.console, arguments)
Re:Firebug lead developer now working on Web dev tools at Go... by Inviz on Sunday July 17, 2011 @11:44PM (#2775033)
See? There's the problem. Since there's no conclusion between vendors on console object API, console.log function may not have .apply method.

It's not only the console object functions actually, most of the browsers choke on a [1,2,3].forEach(alert) and other [Native Code] functions.

Re:Firebug lead developer now working on Web dev tools at Go... by gonchuki on Wednesday July 20, 2011 @03:33PM (#2787083)
Function.prototype.apply.apply(console.log, [console, arguments]);

Works both on IE9 broken console.log, and regular console.log from other vendors. Same hack as using Array.prototype.slice to convert arguments into a real array.

Re:Firebug lead developer now working on Web dev tools at Go... by grandalf on Sunday July 17, 2011 @08:03PM (#2774576)
I have been using that approach and for some reason IE8 still errors!