Is there a reason (performance or other) not to use backtick template literal syntax for all strings in a javascript source file? If so, what?
Should I prefer this:
var str1 = 'this is a string';
over this?
var str2 = `this is another string`;
The most significant reason not to use them is that ES6 is not supported in all environments.
Of course that might not affect you at all, but still: YAGNI. Don't use template literals unless you need interpolation, multiline literals, or unescaped quotes and apostrophes. Much of the arguments from When to use double or single quotes in JavaScript? carry over as well. As always, keep your code base consistent and use only one string literal style where you don't need a special one.
Always use string literals. In this case YAGNI is not correct. You absolutely will need it. As some point, you will have add a variable to your string, at which point you will either need to change single quotes to backtickets, or use the dreaded '+'.
来源:https://stackoverflow.com/questions/37777677/is-there-a-downside-to-using-es6-template-literals-syntax-without-a-templated-ex