And the data type of string type Type Number

(I) The string type

⑴ string needs to be quoted in JS

⑵ use double or single quotes can be, but do not use Hunzhuo

⑶ can not be nested quotes, double quotes not put double quotes, single quotes not put single quotes

⑷ in the string, can be used "\" as an escape character, when expressed special symbols can be used "\" escape

⑸ output literal string str

alert("str");

Output variable str

alert(str);

 

㈡Number type

1. JS Number values ​​are all types, including integer and floating point (decimal)

// number 123 
var A = 123; 
// string 123 
var B = "123";

 

2. typeof operator can use to check a type of a variable

Syntax: typeof variable

Check the string, it returns string

Check value, it will return number

 

3.JS may represent the maximum number:

Number.MAX_VALUE    1.7976931348623157e+308

 

4.JS numbers can represent a minimum value:

Number.MIN_VALUE 5e-324 is greater than the minimum value of 0

 

Number 5. If digital representation exceeds the maximum, it returns a Infinity

 Infinity represents positive infinity - Infinity representing negative infinity

 Infinity is a literal, it is designed to represent a positive infinity

Infinity will return with a check number typeof

 

6.NaN is a special number, indicates Not A Number

NaN is a literal, so do not add "" double quotes

Use typeof NaN also returns a check number

 

 

 

 7. integer in JS ensure accurate operation can be substantially

 

 If a floating-point operations for JS, inaccurate results may not be a

 

 So do not use JS to carry out precision operations require a relatively high

 

Guess you like

Origin www.cnblogs.com/shihaiying/p/11871789.html