In JavaScript, method names are case-sensitive. Keywords, variable names, function names, and all identifiers in JavaScript must adopt consistent character case, and codes are generally written in lowercase characters.
The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.
Variable names and function names in JS are case-sensitive
1. Variable names, for example:
var a = '1'; alert(A);
This will pop up the variable being undefined.
2. Method name, for example:
function Hello(){ alert("hello"); } hello();
will report: Uncaught ReferenceError: hello is not defined, the method is not defined.
Summary: When writing function names and method names in JS, you need to pay attention to keeping the capitalization consistent.
JavaScript is a case-sensitive language, and the naming of variable methods is strictly case-sensitive. Example: var abc and var Abc are two impossible variables.
When using keywords, variables, function names, and all identifiers in JavaScript, 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.
Related recommendations: javascript learning tutorial
The above is the detailed content of Are JavaScript method names case-sensitive?. For more information, please follow other related articles on the PHP Chinese website!