Home  >  Article  >  Web Front-end  >  javascript naming rules variable naming rules_basic knowledge

javascript naming rules variable naming rules_basic knowledge

WBOY
WBOYOriginal
2016-05-16 18:33:54991browse

Hungarian nomenclature for JavaScript variables
Hungarian nomenclature syntax:

Variable name = type + object description
Type refers to the type of the variable
Object description refers to the full name or part of the name of the object, which requires Make the meaning clear and the name should be easy to remember and understand.
Tip: Although JavaScript variables do not have types on the surface, JavaScript internally assigns corresponding types to variables.

Tips: Hungarian nomenclature was invented by a Microsoft programmer. Most C and C programs use this nomenclature.

JavaScript variable Hungarian named type

JavaScript变量起名类型 变量命名前缀
Array 数组 a
Float 浮点 l
Function 函数 f
Integer(int) 整型 n
Object 对象 o
Regular Expression 正则 r
String 字符串 s
Example of Hungarian nomenclature for JavaScript variable names
var sWebURL="www.jb51.net";
It can be seen from the name of the variable that s represents the string WebURL is the website address.

var nCheckCount=5;
It can be seen from the name of the variable that n represents Integer (integer) and CheckCount represents a certain quantity.

Using Hungarian nomenclature is very simple and intuitive, which makes it easy to determine the type of variables and facilitates the reading and maintenance of the program.
Statement:
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