Interpolation question


When I wrote the code below in the coding page, both of them showed "My favorite animal: Koala".
So, I just can't understand the difference between "+" and "," inside the console.log.

console.log('My favorite animal: ', 'Koala');
console.log('My favorite animal: ' + favoriteAnimal);


First one is property of console.log(), we can print tons of items just separating them using commas. It provides a default space between items.


console.log(1,2,3,4) // will print 1 2 3 4

In second code , we are having interpolation process where we are inserting a variable and its getting evaluated as a string value then concatenated with string.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.