初歩的すぎて申し訳ないのですが、変数名の付け方に悩んでます。
JSは初心者です。
####大文字小文字、アンダーバーの使い分けがわからない
変数名の命名規則/**ケースの使い分け
上の記事で、色々紹介されてますが、大文字のみとか使いかたがわからない。
const GLOBAL_OBJECT = 'test'; // どんなときに使う? const objectItem = 'test'; // どんなときに使う? const _obj = 'test'; // どんなときに使う?
####clickなどアクションを起こす要素
classはダメ
よく使う変数名って何?
また頭にアンダーバー入れたりするのか。
const class = 'test'; // NG 予約語 const target = 'test'; // これ? const object = 'test'; // これ? const element = 'test'; // これ? const tar = 'test'; // これ? const obj = 'test'; // これ? const elm = 'test'; // これ? const _tar = 'test'; // これ? const _obj = 'test'; // これ? const _elm = 'test'; // これ?
####一度ごにょごにょしてから変数に入れる時
一行で書けない?一回処理してから入れるときに名前に悩む
const target = '#test'; const replace = target.slice(1); const _tar = document.getElementById(replace);
####状態を表す場合
is〜という名前にするのが良さそうな気がしました。
const isOpend = ''; const is_opend = 'test';
####forのカウント
どこかの記事で、i〜nまで使うことが多いと読んだ気がします。
i++; //i,j,k,l,m,n
その他、よく使う変数名ってどんなものでしょうか?
回答1件
あなたの回答
tips
プレビュー