Home > Web Front-end > JS Tutorial > What must a variable start with javascript

What must a variable start with javascript

醉折花枝作酒筹
Release: 2021-07-15 15:03:21
Original
5085 people have browsed it

In JavaScript, giving a variable a name (variable naming) must start with a letter, underscore, or dollar sign; it is case-sensitive; JS keywords or reserved words are not allowed.

What must a variable start with javascript

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

In order to distinguish boxes, we can use names such as BOX1 and BOX2 to represent different boxes. BOX1 is the name of the box (that is, the name of the variable).

Let’s quickly give the variable a good name! The variable name can be chosen arbitrarily, but the name must follow some rules:

1. It must start with Begins with a letter, underscore, or dollar sign, and can be followed by letters, underscores, dollar signs, and numbers. As follows:

正确:           
    mysum            
    _mychar         
    $numa1
Copy after login
错误:  6num  //开头不能用数字
  %sum //开头不能用除(_ $)外特殊符号,如(%  + /等)
  sum+num //开头中间不能使用除(_ $)外特殊符号,如(%  + /等)
Copy after login

2. Variable names are case-sensitive, for example: A and a are two different variables.

3. JavaScript keywords and reserved words are not allowed to be used as variable names.

[Recommended learning: javascript advanced tutorial]

The above is the detailed content of What must a variable start with javascript. 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