LoginSignup
1
0

More than 1 year has passed since last update.

テンプレート文字列の使い方

Last updated at Posted at 2022-02-08

自己紹介

現在都内の企業でWebエンジニアのインターン生としてお世話になっている大学2年生です!
インターンや個人開発で学んだことや苦労したことを記事にしています!
よろしくお願いします🙇🏻‍♂️

はじめに

今回はJavaScriptのテンプレート文字列についてアウトプットしていきます!

使用例

const nameArray = ["鈴木", "佐藤", "田中"];
//今までの書き方
nameArray.map((name, index) =>
  console.log((index + 1) + "番目は" + name + "です。")
);
//テンプレート文字列を用いた書き方
nameArray.map((name, index) =>
  console.log(`${index + 1}番目は${name}です。`)
);

テンプレート文字列を用いることで簡潔で見やすいコードが書ける。

1
0
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
0