JavaScript authoritative guide expressions and operators

Source: Internet
Author: User

If one of the variables in the expression x is increased by 1, the variable is used in the expression Z, then the value of X is computed first and then the value of Z is computed.

A=1;

Seeking b= (a++) +a;

1) Calculation b

2) Calculate the a++ (assuming C)

3) Calculate a

4) Calculate C+a 5

) Assign the C+a to B

The result of the a++ is still 1, that is, C is 1, then a immediately increases 1, execution 3) when a is already 2, so B is 3

+ operator

If one of the operands is an object, the Date object performs the conversion through the ToString () method, and the other objects are converted through the ValueOf () method (if ValueOf () returns a raw value). Because most objects do not have the ValueOf () method available, they are converted through the toString () method. After converting an object to the original value, if one of the operands is a string, and the other operand is also converted to a string otherwise, two operands are converted to a number (or Nan)

"1" + 2 = "12";

1 + {} = 1[object object]; Convert object to String

True + true = 2;

2 + null = 2;

2 + undefined = NaN; Undefined conversion to Nan

Inch

The left operand is a string or can be converted to a string, and the right operand is an object. Returns true if the object on the right has a property name that is named left operand value

instanceof

The left operand is the object, and the right operand identifies the class of the object. Returns true if the left-hand object is an instance of the right-hand class.

typeof

x typeof (X)

Undefined "undefined"

Null "Object"

True or false "Boolean"

Any digit or nan "number"

Arbitrary string "string"

"Function" of arbitrary functions

Any built-in object (non-function) "Object"

Strings implemented by any host object compiler

Delete

Delete an object property or array element

var a = [n/a];

Delete A[1];

Alert (a.length)//3 Deleting an element does not change the length of the array

void

Operands are calculated as usual, but ignoring the results and returning undefined is most commonly used in client url--javascript:url, where the expression with side effects can be written in the URL, void so that the browser does not have to display the result of the expression.

<a href= "Javascript:void window.open (); > Open a new Window

JavaScript authoritative guide expressions and operators

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.