js basis - calculating simple data types

to sum up:

Any character string data is simply added splicing operation.

If a string which is purely digital, and digital subtraction for multiplication and division remainder operation mode, the string is converted into a digital implicit involvement operation; a Boolean Save mode than multiplication and division arithmetic, Boolean values ​​are converted to digital implicit involvement operation.

Digital and digital operations are normal.

And digital operation null, null operation is converted into 0 participation.

Digital and boolean operations, Boolean values ​​are converted to a true, false Boolean value 0 is converted to participate in operation.

And undefined number calculation, the result is NaN.

NaN any data type calculation result is NaN.

 

If you pay attention to the following two points, that is not found on top of a mouthful:

  1. Operation of the first press it in digital standard, can be converted into a digital implicit priorities are converted into numbers: In this case, the calculation result is either correct mathematical calculation, or is NaN3;

  2. However, this process there is an exception to the string, the string is added to any data type operations are spliced, any data type string Save I first operation mode with reference to multiplication and division.

 

reference:

https://www.haorooms.com/post/js_czf_mst  operator operation

https://www.haorooms.com/post/js_yinxingleixing  double recessive conversion

 

Guess you like

Origin www.cnblogs.com/hubyq/p/11322524.html