Singles' Day Javascript Interpretation Section II in 2014: Singles' Day in 2014

Source: Internet
Author: User

Singles' Day Javascript Interpretation Section II in 2014: Singles' Day in 2014

In this section, we will explain the Javascript syntax. Although the Javascript language is very simple, its syntax is relatively easy to learn, but it will not be learned in short. Therefore, let's take a look at it.

*************

1. We usually use annotations to mark some code, which makes us better understand the program code we have previously written. These annotations are not interpreted and executed, but they are very useful.

2. javascript supports single-line comments starting with a C ++ style //, that is, the parts after two diagonal lines are treated as comments until the end of this line, they are not interpreted by computers.

3. Javascript also supports C language-style comments starting with/* and ending with multiple lines of comments. All content from the beginning to the end is treated as comments.

4. next we will talk about the function of Annotation. There are two main functions of annotation: the first is to explain the code, and the second is to debug the program, that is to say, when we want to determine the execution effect of a program, we can comment it out first, observe the running result, then release the comment, run it again, and compare it, you may find the source of the problem.

 

************

1. Like most programming languages, Javascript also supports variables, which are case sensitive to variable names.

2. The Javascript variable name must start with a letter followed by a letter, number, or underline. Maybe PHP or Perl users prefer to start with $. This can also be done in Javascript, but it is not recommended.

3. javascript variables are mainly of the Number, String, Null, Undefined, Boolean, and Object types, and they are weak programming languages, that is, we do not need to specify its type when defining variables.

4. The value assignment of variables is the same as that of most programming languages. The value is assigned with the = sign. For these types, we will demonstrate them through the js Code below:

Var x; // at this time, x is of the undefined type var x = 5; // at this time, x is of the numerical type var x = 'X'; // at this time, x is a string var x = true; // at this time, x is a Boolean var x = false; // at this time, x is a Boolean var person = {name: "xinxing", age: 23}; x = null; // clear the value of the variable. The type is null.

5. Strings in Javascript can be single or double quotation marks. There is no difference between them.

6. We can assign null values to a variable to modify its data type.

 

 

* *********** Operators in Javascript **************

1. The operators in Javascript are also very similar to other programming languages. Common = is used for assignment, + is used for addition, * is used for multiplication,/is used for division, and % is used for modulus.

2. In addition, Javascript supports the ++ and -- auto-increment and auto-subtraction operators.

3. there are also operators such as + =,-=, * =,/=, and % =, which are the same as most other languages. For example, x + = y indicates x = x + y.

4. Strings can also be connected with a plus sign (+), which is also supported in many languages and is a natural expression.

5. If a number and a string are computed with +, a string is returned.

 

* ********** Comparison operators and logical operators ************

1. The comparison operations in Javascript are also the same as those in many languages. To ensure rigor, I 'd like to give a brief introduction.

2. We use = to indicate equal to, = to indicate that not only the values are equal, but also the types must be the same ,! = Indicates not equal to, <= indicates less than or equal to,> = indicates greater than or equal to, <indicates less than,> indicates greater than. In addition ,! = Indicates that the value is definitely not equal, that is, the value is not equal and the type is also different.

3. The comparison operator returns a Boolean value.

4. We use logical operators to perform operations on Boolean variables, including & representing logic and operations, | representing logic or operations ,! Indicates logical non-operation.

5. In addition, Javascript also supports the three-object operator, that is, the following expression:

variablename=(condition)?value1:value2 

 

**************

1. We can directly declare a variable using the var keyword, as shown in the following code:

var xinxing;

2. After the declaration, the variable will not store any value. We can assign values to it using the value assignment number, for example:

Xinxing = "Xin Xing ";

3. Of course, you can also declare and assign values at the same time:

Var xinxing = "Xin Xing ";

4. If the variable already exists, redeclaring it will not change its value.

 

************

1. Javascript, as a programming language, has the capabilities of common programming languages and its own data types and operators.

2. But as a scripting language and a front-end scripting language, we will not spend too much effort on it.




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: info-contact@alibabacloud.com 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.