STOP using console.log() in 2022!

·

1 min read

If you started learning Javascript then I can bet you that the first line of code you wrote was

console.log("Hello World!");

We all use console.log() a lot in our Javascript code for debugging and sometimes we write it just for fun😉.

Usually, we use console.log() like this:

// old way
console.log("Hello World!"); //Hello World
console.log(4+4); //8

We can optimize a little bit by using the arrow function like this:

// new and efficient method
const l=(args)=>{
  console.log(args);
}
l("hello World!"); ////Hello World
l(4+4);  //8

Writing the function one's you can now just use l to make things work.

WHY to do this

  • It makes your code DRY
  • Gives your code aesthetics and makes it look neat.
  • Saves a little bit of time.
Â