1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Javascript】テンプレートリテラル(テンプレート文字列)

Posted at

文字列の中に式や変数を埋め込むことができる

書き方
var name = "ペンギン";
var age = 30;

console.log("こんにちは。私は" + name + "です。" + age + "歳です。");



console.log(`こんにちは。私は${name}です。${age}歳です。`);
こんにちは。私はペンギンです。30歳です。

改行文字がそのまま改行として扱われる

書き方
var msg = `こんにちは。
私はペンギンです。
30歳です。`;

console.log(msg);
こんにちは。
私はペンギンです。
30歳です。
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?