ecmascript:template_literal
文書の過去の版を表示しています。
Template Literal
テンプレートリテラル
const a = 'world';
const s = `Hello ${a}!`;
console.log(s) // => Hello world!と出力
タグ付きテンプレートリテラル
function uc(strings, ...values) {
return String.raw({raw: strings}, ...values.map(v => v.toUpperCase()));
}
const a = 'world';
const s = uc`Hello ${a}!`;
console.log(s); // => Hello WORLD!と出力
String.rawメソッド
テンプレートリテラルを使わずに、同様の処理を実装できるもの。
const a = "Sun";
const b = "platet";
`the ${a} is not a ${b}.` === String.raw({raw:[ "the ", " is not a ", "."]}, a, b);
ecmascript/template_literal.1540798366.txt.gz · 最終更新: by nullpon