LoginSignup
0
0

More than 3 years have passed since last update.

【javascript】 テンプレートリテラル とは 一言で。

Posted at

【ゴール】

テンプレートリテラルの理解

【テンプレートリテラルとは、、、】

定数や変数を楽して出力できる

不使用の場合
*「+」を2回も。。面倒だな。。。

hoge.js
const name = "太郎";

console.log("私の名前は" + name +"です"); //私の名前は太郎ですが出力

使用した場合

hoge.js
const name = "太郎";

console.log(`私の名前は${name}です`); //私の名前は太郎ですが出力

【具体的な使い方】

①console.log()の括弧内を「``」(バッククォーテーション)で囲む
 ※Macの方は「command + @」です

②変数や、定数で指定したものを${}で囲む

以上。意外と使います。

【合わせて読みたい】

■ 【Javascript】 メソッド まとめ 基礎基本コード メモ
https://qiita.com/tanaka-yu3/items/2438798d159fa402b1d5

■ 【Javascript】JS 変数 定数 違い  一言でまとめました
https://qiita.com/tanaka-yu3/items/51b8b0630a1e4e2d52c8

■ 【JavaScript】 js 繰り返し文 for / while/ case
https://qiita.com/tanaka-yu3/items/942d9d4838ebe14be1c2

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