(6) JavaScript learning notes-expressions and operators

Source: Internet
Author: User

I. Expressions

1. The JS interpreter can calculate it to generate a value;

2. The simplest expression is the direct amount or variable name. The value of the direct amount expression is the direct amount;
[Javascript]
123;
 
"I am a string"
 
(I + 1.7;
 
(A + 3) * sum;

Ii. Operators

1. Most operators are symbols, such as "+" and "-", but some operators are represented by keywords, such as "delete ";

 

 

The P column indicates the priority of each operator. The value of a number is greater than that of a small number.

Iii. Equal operators = and equal operators =

1. = is allowed type conversion, === must be completely equal

2. = rules:

A. If the two values have different types, they are different;

B. If the two values are of the numeric type, they are equivalent if they are not Nan.

C. It is equivalent

D. If the two values point to the same reference, they are equivalent

E. If both are null or undefined, they are equivalent

3 .! = And! = Is the opposite rule

IV. in Operator

1. The number of operations on the left is a string, or can be converted to a string. The number of operations on the right is an object or array;

2. If the left value is an attribute name of the right object, true is returned;

[Javascript]
Var point = {x: 1, y: 1 };
Var has_x_coord = "x" in point; // true
Var has_y_coord = "y" in point; // true
Var has_z_coord = "z" in point; // false
Var ts = "toString" in point; // true

V. instanceof
Returns true if the object on the left is an instance of the right class.

6. String operator www.2cto.com

1. <<=>= the Unicode used to determine the sequence

2. + the priority of string operators is higher than that of numbers

[Javascript]
1 + 2; // 3
"1" + 2; // 12
11 <3; // false
"11" <3; // true
1 + 2 + "abc"; // 3abc
"Abc" + 1 + 2; // abc12

 


By: dxh_0829

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: 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.