Which string concatenation is better?
I wonder which string concatenation is "better", faster, or even both?
Option 1:
let value = "Instance 0"; console.log('Using instance: ' + value);
Option 2 (Template literals):
let value = "Instance 0"; console.log(`Using instance: ${value}`);
Thank you!
It depends. You don’t need to talk about JavaScript anyway. And that’s not so much. But I’d prefer two. If you have a user, he reads it more easily than with +
I find two more legible.
How is it if you want to chain several things?
Still two better?
Multiple strings? Yeah, still. Because you keep reading flow and do not have thousands of irritating plus signs
Clear, compiled languages like C/C++ are faster, but it is not as slow now.
Merci!
But that doesn’t matter because the speed differences are so minimal that they don’t fall into weight.
Depends on the browser/js engine which is faster from both.
Afaik is the first faster in chrome and the second faster in Firefox.