Skip to content

Instantly share code, notes, and snippets.

@cowboy
Created July 7, 2010 01:51
Show Gist options
  • Select an option

  • Save cowboy/466188 to your computer and use it in GitHub Desktop.

Select an option

Save cowboy/466188 to your computer and use it in GitHub Desktop.
for paul
// Console arguments testing
var apc = [].slice;
(function(){
console.log( apc.call(arguments) );
})( "false", 1, undefined, null, ["foo","bar","baz"], {a:1,b:2}, false );
(function(){
console.log.call( console, apc.call(arguments) );
})( "false", 1, undefined, null, ["foo","bar","baz"], {a:1,b:2}, false );
(function(){
console.log.apply( console, apc.call(arguments) );
})( "false", 1, undefined, null, ["foo","bar","baz"], {a:1,b:2}, false );
console.log( "false", 1, undefined, null, ["foo","bar","baz"], {a:1,b:2}, false );
@cowboy

cowboy commented Jul 7, 2010

Copy link
Copy Markdown
Author

Chrome 5 inspector output:

chrome 5 inspector

Note that by default (the bottom two), since strings don't have " around them, "false" and false appear to be the same. This is why I coded JavaScript Debug to not apply arguments in WebKit (the top two).

@paulirish

Copy link
Copy Markdown

IE doesnt handle console.log.apply/call at all, so my these have the middle two examples removed..

IE8 dev tools:

IE9 dev tools:

@paulirish

Copy link
Copy Markdown

Firefox 3.5.10 with firebug 1.6X:

@cowboy

cowboy commented Jul 7, 2010

Copy link
Copy Markdown
Author

At least Firebug colors booleans and strings differently in the "plain ol' arguments" logging mode, but it's still too subtle!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment