What is the difference between console.log(x); AND console.log(`${x} : ${typeof x}`);

Joined
Feb 16, 2024
Messages
5
Reaction score
0
Hi there,

I create a thread because I feel confused about a JS notion. What is the difference between these two console commands?

Let's take an example:

let n1 = "123";

console.log(${n1} : ${typeof n1});
console.log(n1);

Is there any reason to use console.log(${n1} : ${typeof n1}); // -> 123 : number

To me, it makes things more difficult than they have to be.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,286
Latest member
ChristieSo

Latest Threads

Top