Created
February 27, 2013 22:01
-
-
Save soquel/5052196 to your computer and use it in GitHub Desktop.
Shorten console.log() to l()
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
function l() { | |
try { | |
// this works in Firefox/Opera | |
console.log.apply( this, arguments ); | |
} catch (e) { | |
// this is for Chrome/IE | |
var args = [], i = 0; | |
while( i++ < arguments.length ) | |
args.push('arg' + i); | |
new Function( args, 'console.log(' + args.join( ',' ) + ')' ). | |
apply( null, arguments ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment