Javascript | Using object shorthand when debugging

Vipin Cheriyanveetil
1 min readOct 5, 2023
Photo by Louis-Philippe Poitras on Unsplash

Hello All,

I just found this on Internet and thought it would be nice and useful to all programmers. It helped me a lot when i debug things on my console.

Note: The same article can be found at my personal blog at

https://buddyclaps.com/javascript-using-object-shorthand-when-debugging/

When using console.log() in Node.js it can be hard to spot and understand variables you’re logging in your terminal, especially if they’re empty .

We now have a shorthand trick for it. Wow I am loving node.js now.

Use object shorthand so that every value has a name next to it e.g.

console.log({ var1, var2 });

Output

{ var1 : 23, var2: 'hello world' }

I had this difficulty to understand what is getting printed on my terminal. But now i have this hack or trick.

Hope thats useful. Please try and let me know.

Happy programming :)

--

--