Last Updated: February 25, 2016
·
910
· igcorreia

Console.log like a boss! Fastests approach

I use this every day in every project!

First:

function log(a){
       console.log(a);
}

Then:

log('Hello');

I hate right console.log all day long :)

4 Responses
Add your response

function log() {
  console.log.apply(console, [].slice.call(arguments, 0));
}

log('hello', 'world');
log('%c this sentence is coloured', 'background-color: yellow; color: blue');

this way you still support multiple arguments ;)

over 1 year ago ·

Like it :)

over 1 year ago ·

Cool :)

over 1 year ago ·

Cool :)

over 1 year ago ·

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside