JavaScript 入門指南 - 變數命名規則
通常是用英文單字或縮寫替識別字命名,注意不能用數字當開頭,以下為合法的變數名稱
| variable_name_codeCODE_1234a1234someThingSomeThing | 
另外須注意 JavaScript 的所有保留字 (reserved word) 包括關鍵字 (keyword) 都不能當作識別字名稱。所有保留字列表如下
| abstract | boolean | break | byte | 
| case | catch | char | class | 
| const | continue | debugger | default | 
| delete | do | double | else | 
| enum | export | extends | false | 
| final | finally | float | for | 
| function | goto | if | implements | 
| import | in | instanceof | int | 
| interface | long | native | new | 
| null | package | private | protected | 
| public | return | short | static | 
| super | switch | synchronized | this | 
| throw | throws | transient | true | 
| try | typeof | var | void | 
| volatile | while | with | 
變數或常數都可以當作運算元 (operand) ,運算元與運算子 (operator) 構成運算式 (expression) 。接下來,我們繼續看到運算式與陳述(statement) 。
Reference : http://pydoing.blogspot.tw/2012/12/JavaScript-Variable-Naming.html
 
沒有留言:
張貼留言