PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Blocks

    Design blocks for your website

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Written By

It's 2022, don't use the console.log(😎)

It's 2022, don't use the console.log(😎)

We as Javascript developers usually console.log() stuffs to test the output or just for fun. Even, I can bet that our (include me ✌️) first code was "Hello world" logged in the console.

console.log("Hello World!")

This piece of code has been nostalgic for all fellow JS developers. But now it's 2022, let's make it a little handy and comfortable for our fingers.

In this article, I have discussed a simple and common method that has rarely been used by developers.

Let's get started

As we know, we all use to log the data to console like this...

console.log("I love js") // I love js

console.log(4 + 4) // 8

console.log(!true)  // false

Let's work a little smarter and more efficient 😎

const log = (arg) => console.log(arg)

Here, we have created a function with a shorter name - log relative to console.log(), you can even use a shorter name, Ummm 🤔 something like this...

const l = (arg) => console.log(arg)

So, you might be wondering what's the benefit of writing code like this? Let's discuss the benefits.

Benefits

  • Keeps your code clean and slick
  • Improves readability
  • Relief to your fingers, don't have to write a long thing

comment more benefits if you can...

Let's test 🚗

log("Hello world") // Hello world
log(4 + 4) // 8
log(!false) // true
log(Math.PI) // 3.141592653589793

Try yourself - fiddle

Conclusion

So, this was a quick tip to save your time and make your code look cleaner. Let me know in the comments if you will use this tip.

You can try the same thing for console. info(), console.warn(), console.error()


Feel free to reach me out via Twitter - @codewithsnowbit

🌏 Let's connect

Stay tuned for the next article. Stay safe and Happy Coding!

If you enjoyed and find my content helpful, than you can check this out Buy me a coffee

Comments (0)

loading comments