Javascript series: ecmascript syntax Variables

Source: Internet
Author: User

1. Syntax

Basic ecmascript concepts:

BytesCase Sensitive. Variables, function names, operators, and everything are case sensitive.

BytesThe variable type is weak.. Variables in ecmascript do not have a specific type. when defining a variable, you only need to use the VaR operator to initialize the variable to any value. You can change the type of data stored in the variable at any time.

BytesThe semicolon at the end of each line is optional. Ecmascript allows developers to determine whether to end a row with a semicolon.Code. If there is no semicolon, ecmascript regards the end of the line of code as the end of the statement, provided that the meaning of the Code is not broken. The best way to write code is to always add a semicolon without a semicolon. Some browsers may not be able to run correctly.

BytesNote. Ecmascript has two types of Annotations: single-line and multi-line annotations. A single line comment starts with //. A multi-line comment starts with/* and ends.

BytesParentheses indicate code blocks. A code block indicates a series of statements that should be executed in sequence. These statements are encapsulated between {And.

2. Variables

Variables in ecmascript use the VaR operator and variable name definition. You can use the VaR statement to define one or more variables. Variables in ecmascript do not need to be initialized.

Developers should develop good programming habits. Although javascript can assign multiple data types to a variable, this method is not recommended.When using a variable, the same variable should only store one data type.

Two rules for variable names:

The first character of the period must be a letter, underscore (_), or dollar sign ($)

The remaining characters of the delimiter can be any character.

The secret variable name cannot be a keyword or reserved word.

Camel markup-the first letter is lowercase, And the next words start with an uppercase letter.

◊ Pascal markup-the first letter is in upper case, and the subsequent words start with an upper letter.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.