DEV Community

Discussion on: Three types of console.log users. Which one are you?

Collapse
 
allanjeremy profile image
Allan N Jeremy • Edited

Method two: Template literals (ES6+)

By wrapping a string in backticks you can append a variable to the string by putting it inside ${}.

console.log (`my variable : ${myVariable}`);
Collapse
 
waylonwalker profile image
Waylon Walker

This is the way I should do it, 😜

Collapse
 
allanjeremy profile image
Allan N Jeremy • Edited

😁 either this or the other one, the other option does have its advantages (e.g. printing an object or other non-primitives without having to JSON.stringify it)