Home > Article > Web Front-end > Is javascript case sensitive?
distinguish. JavaScript is a strictly case-sensitive language. When entering keywords, variable names, function names, and all identifiers, you must use consistent character case; in order to avoid input confusion and grammatical errors, lowercase characters are generally used. Write code.
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
javascript is case sensitive.
Javascript is a strictly case-sensitive language, so Hello and hello are two different identifiers.
When entering keywords, variable names, function names, and all identifiers, you must use consistent character case.
In order to avoid input confusion and grammatical errors, it is recommended to use lowercase characters to write code. In the following special cases, uppercase forms can be used:
1. It is recommended that the first letter of the constructor be capitalized. Constructors are different from ordinary functions.
Example
The following example calls the predefined constructor Date(), creates a time object, and then converts the time object into a string for display.
d = new Date(); //获取当前日期和时间 document.write(d.toString()); // 显示日期
2. If the identifier consists of multiple words, consider using camel nomenclature - except for the first word, the first letters of subsequent words are capitalized. For example:
typeOf(); printEmployeePaychecks();
Tip: The above are general conventions and do not constitute mandatory requirements. Users can name them according to their personal habits.
But be aware that HTML is not case-sensitive, which can be easily confused since it is closely related to client-side JavaScript. Many JavaScript objects and properties have the same names as the HTML tags and properties they represent.
In HTML these tags and property names can be entered in any case, but in JavaScript they are usually lowercase. For example, in HTML, the event handler property onclick is usually declared as onClick, but in JavaScript code only onclick can be used.
[Related recommendations: javascript learning tutorial]
The above is the detailed content of Is javascript case sensitive?. For more information, please follow other related articles on the PHP Chinese website!