JavaScript is case-sensitive, it means that variables, function names, language keywords, and other identifiers must be typed with a constant capitalization of letters.
For example, the variable firstVar must be typed firstVar, not FirstVar or firstvar. Similarly, the method name getElementById() must be typed getElementById() not as getElementByID().
In the above example the variables myName and myname, are two different variables.
Whitespace and Line Breaks:
JavaScript does not consider spaces, tabs, and newlines that appear in the JavaScript programs. You can use spaces, tabs, and newlines easily in your JavaScript program and you can format and indent your programs in a neat and consistent way that makes the code easy to read and understand.
Semicolons are Optional:
The statements in JavaScript are normally followed by a semicolon, just as they are in C, C++, and Java. JavaScript allows you to omit the semicolon if each of your statements is placed on a new line.
For example, you can write the following code without semicolons.
Note: It is a good practice to use semicolons while programming.
JavaScript Identifiers:
Identifiers in JavaScript are names given to variables, functions, etc. Identifiers in JavaScipt are the same as identifiers in other programming languages like C, C++, Java, etc.
While naming JavaScript variables, keep the following rules in mind:
Don't use any of the JavaScript reserved keywords as a variable name.
JavaScript variable names should not start with numbers (0-9). They must start with a letter or an underscore character.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok