Home > Web Front-end > JS Tutorial > body text

Detailed explanation of JavaScript variable naming rules you must know_Basic knowledge

WBOY
Release: 2016-05-16 17:34:17
Original
1173 people have browsed it

Variable naming should also comply with one of the following famous naming rules:

Famous variable naming rules
Camel notation
The first letter is lowercase, and the following letters all start with uppercase characters. For example:

Copy code The code is as follows:

var testValue = 0, secondValue = "hi" ;Pascal notation

starts with an uppercase letter, and all subsequent letters begin with an uppercase character. For example:
Copy code The code is as follows:

var TestValue = 0, SecondValue = "hi" ; Hungarian type notation

Appends a lowercase letter (or sequence of lowercase letters) before a variable named in Pascal notation to indicate the type of the variable. For example, i represents an integer and s represents a string, as shown below "
Copy the code The code is as follows:

var iTestValue = 0, sSecondValue = "hi";

The following table lists some commonly used prefixes to make the sample code easier to read:
类型 前缀 示例
数组 a aValues
布尔型 b bFound
浮点型(数字) f fValue
函数 fn fnMethod
整型(数字) i iValue
对象 o oType
正则表达式 re rePattern
字符串 s sValue
变型(可以是任何类型) v vValue

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template