2

現在、ESLintの優先テンプレートを使用して、文字列連結の代わりにテンプレート文字列を強制的に使用しています。

これにより、テンプレート文字列形式よりも通常の文字列を使用する必要があるかどうかを考えさせられました。

console.log('Why use this? It requires me to escape different quotes depending on the context. In this case  \'.');
console.log(`When I can use this. It allows me to use all types of quotes (e.g. ', ") without ever worrying about escaping them.`);

JSPerf は理想的なプロファイリング ツールではないことを認識していますが、少なくとも静的な文字列の場合、http://jsperf.com/es-string-vs-templateなどのパフォーマンスの低下は見られません。

4

1 に答える 1

2

そうです、パフォーマンスの違いはないはずです。

orの代わりに`and を必ずエスケープする必要があります。${'"

于 2015-08-28T10:28:08.440 に答える