Home>Article>Web Front-end> Is case sensitive in javascript?

Is case sensitive in javascript?

青灯夜游
青灯夜游 Original
2021-06-15 18:01:51 3668browse

Javascript is case sensitive. JavaScript is a case-sensitive language. When entering language keywords, variables, function names, and all identifiers, you must use consistent character case.

Is case sensitive in javascript?

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer

JavaScript is case-sensitive Language, which means that when entering language keywords, variables, function names, and all identifiers, you must use consistent character case.

For example, the keyword "while" must be entered as "while" and cannot be entered as "While" or "WHILE". Similarly, "online", "Online", "OnLine" and "ONLINE" are four different variable names.

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.

Extended information: Naming rules and specifications of variables

1), Naming rules of variables in JavaScript

You must abide by the naming rules, otherwise the code An error will be reported and cannot be executed.

a. The variable name can contain letters, numbers, dollar signs ($) or underscores (_), but must start with letters, dollar signs ($) or underscores (_). It cannot Start with a number.

Note: Hyphens (-) or periods (.) cannot be used in variable names.

b. Keywords or reserved words cannot be used to name variables.

2), naming convention

If you don’t follow it, you will not get an error and can execute it, but front-end programmers all over the world are complying with it.

a. The variable name should be meaningful. When you see the variable name, you will know what kind of data is stored in it.

b. It is best to use English words. If pinyin is not available, you can do it.

c. Use camel case nomenclature. One word is all lowercase, and the first letter of multiple words is capitalized starting from the second word.

[Related recommendations:javascript learning tutorial]

The above is the detailed content of Is case sensitive in javascript?. For more information, please follow other related articles on the PHP Chinese website!

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