LoginSignup
0
0

More than 3 years have passed since last update.

JS~変数名と定数名~

Posted at

Jsでの変数名と定数名について学習していきます。

変数名

変数名にはいくつかの条件があります。

1. アンダースコア、ダラマーク、数字が使用可能
2. 半角スペースは使えない
3. 一文字目に数字は使えない
4. 予約語は使えない

*予約語とは??▶Jsにある将来使われる可能性のある、またはすでに使われている言葉です。

<予約語一覧>
break/case/catch/class/continue/debugger/default/delete/do/else/enum/export/extends/finally/for/
function/if/implements/import/in/instanceof/interface/let/new/package/private/protected/public/
return/static/super/switch/this/throw/try/typeof/var/void/while/with/yeild

*大文字と小文字に注意!!
mynameとmyNmameは区別されるので注意してください!
また複数の単語を付ける場合は、一文字目は小文字にして2単語目は大文字にします。

jsでは『let』をつかい、宣言します。

定数名

定数名の命名規則も変数名と同じです。
jsでの宣言は『const』を使います。

let fruit = "りんご" #変数宣言
const fruit = "りんご" #定数宣言
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