Why doesn't javascript function aliasing work?

Posted by codeninja on Stack Overflow See other posts from Stack Overflow or by codeninja
Published on 2010-04-16T15:03:04Z Indexed on 2010/04/16 15:23 UTC
Read the original article Hit count: 312

Filed under:
|
|
|
|

I have some Firebug console function calls that I wanted to disable when Firebug wasn't enabled, e.g. console isn't defined. This works fine in IE6 and FF3, but not in Chrome:

var log;

if(console){
  log = console.log;
}else{
  log = function(){ return; }
}

I get an "Uncaught TypeError: Illegal Invocation" in Chrome =/

I read about the issue here, where you have to apply a context, which is kind of new to me... and I can't seem to figure how to accomplish the above in all browsers...

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about function