Learning Goals
1. Mastering The data types of JavaScript
2. mastering The typeof operator
3. Mastering Undefined
4. Master Null
data types for JavaScript
There are 5 simple data types (also known as basic data types) in ECMAScript:
Undefined, Null, Boolean, number, String.
There are also 1 kinds of complex data types:Object.
Typeof
syntax:typof space variable or typof(variable)
Features: Detecting variable types
return value:stying Type, possibly:string,number,boolean , Object , undefined , function
Undefined
the Undefined type has only one value, that is, a special Undefined.
Disclaimer: In general, there is no need to display a variable set to the undefined value.
Null
a 1.null value represents an empty object pointer
2. If the defined variable is intended to be used to hold the object in the future, it is better to initialize the change to null instead of the other value.
Description:The undefined value is derived from a null value, so undefined==null, the return result is true .
JavaScript Data Types
Learning Goals
1. Master number
2. Mastering IsNaN ()
3. Mastering Numerical Conversions
(1),number ()
(2),parseint ()
(3),parsefloat ()
Number
Number: represents integers and floating-point numbers
NuN: That is, a non-numeric value (notanumber) is a special value.
Description
1. any operation involving nan (for example, NAN/10) will return nan.
2.NaN is not equal to any value, including the NaN itself.
IsNaN ()
syntax:isNaN(n)
function: Detects if n is "non-numeric"
return Value:Boolean
parameter: Parameter n can be of any type
Description:IsNaN() attempts to convert this value to a numeric value after it has received one.
Some values that are not numeric are converted directly to values.
numeric conversions
there are 3 functions to convert a non-numeric value to a value: number(),parseint(),parsefloat ().
which Number() can be used for any data type, while parseint() and parsefloat specifically convert the string to a numeric value.
parseint() integer
parseint() ignores the spaces in front of the string until the first non-whitespace character is found.
Description: 1.parseInt(): Convert null character returns NaN.
2.parseInt() This function provides a second argument: the cardinality used when converting
Paesrfloat() floating point number
Parsefloat: Parses each character starting from the first string until it encounters an invalid floating-point number character.
Note: In addition to the first decimal point,the second difference between parsefloat () and parseint () is that it will always ignore the leading 0.
JavaScript Data Types
Learning Goals
1. Mastering String
2. Mastering the string turn
(1)String()
(2)toString()
3. Mastering The Boolean
4. Mastering Type Conversions
String
The string type is used to represent a sequence of characters consisting of 0 or more of the four-bit Unicode characters, the string. The string can be represented by double quotation marks ("") or single quotation marks (' ').
ToString () and String ()
Syntax:str.tostring ()
function: convert str to a string
return value: a copy of str
parameters:str is the content to be converted, which can be numeric, Boolean, object, String.
Description: You can also use the String () function if you do not know if the value to be converted is null or undefined . It is able to convert any type of value to a string.
Boolean
used to indicatetrue or false, True to indicate false
Type conversions
1. All numbers except 0 , converted to Boolean are true
2. All characters except "" are converted to Boolean type true
3.Null and undefined are converted to Boolean type false
JavaScript Data Type-2