テンプレートリテラルは文字列の中に変数が書けて便利なのですが、
改行が面倒です。
改行時にスペースを抜きたいのですが、難しいですよね?
便利にかける方法ってありますか?
■ スクリプト
(() => { const type = 'verify'; const template = `test: ${type};`; console.log(template) })()
■ コンソールログ
% node templateLieral.js test: verify;
↓ 下記のように書けたらいい
(() => { const type = 'verify'; const template = `test: ${type};`; // スペースが含まれてしまう console.log(template) })()
% node templateLieral.js test: verify;

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2023/02/14 06:17