LoginSignup
0
1

[Ruby JavaScript] 式展開比較

Posted at

目的

フロントエンドをVue.js(JavaScript)、バックエンドをRails(Ruby)のアプリケーションを作成しており、
式展開の書き方がどちらの言語の書き方なのか混乱したのでまとめる

式展開とは

文字列の中に式を入れることができる機能

javascriptの式展開

`${式}`

  • バッククオートで囲む
const name = "伊藤"
console.log(`名前は${name}です`)
> 名前は伊藤です

rubyの式展開

"#{式}"

  • ダブルクオーテンションで囲む
name = "伊藤"
print("名前は#{name}です")
> 名前は伊藤です

参考にさせていただいた記事

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