Skip to content

Instantly share code, notes, and snippets.

@Tomokatsu-Sakamoto
Created February 20, 2022 01:01
Show Gist options
  • Save Tomokatsu-Sakamoto/6a704f01db2fb237ab7cb34c7fb28d99 to your computer and use it in GitHub Desktop.
Save Tomokatsu-Sakamoto/6a704f01db2fb237ab7cb34c7fb28d99 to your computer and use it in GitHub Desktop.
function myFunction() {
// ダブルクォーテーションの中には、シングルクォーテーションが表記できる
let mes1 = "’90 に"; // 文字列の両端は "(ダブルクォーテーション)でもOK
console.log( mes1 );
// シングルクォーテーションの中には、ダブルクォーテーションが表記できる
let mes2 = '"山" と'; // 文字列の両端は ’(シングルクォーテーション)でもOK
console.log( mes2 );
// \(バックスラッシュ:半角文字の¥)を書くとダブルクォーテーションの中にもダブルクォーテーションが表記できる
let mes3 = "\"川\" と";
console.log( mes3 );
// `(バッククォート)で囲むのも OK
let mes4 = `この中には " も ' だって記述できる。\` はエスケープが必要`;
console.log( mes4 );
let mes5 = `${mes1}は ${mes2}${mes3} "海" に遊びに行った。`;
console.log( mes5 );
let mes6 = `${mes1}は
${mes2}
${mes3}
"海" に遊びに行った。`;
console.log( mes6 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment