Is javascript case sensitive?

青灯夜游
Release: 2021-12-08 16:26:50
Original
5774 people have browsed it

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.

Is javascript case sensitive?

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());  // 显示日期
Copy after login

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();
Copy after login

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!