Javascript data type, javascript
Key points:
1,TypeofOperator
var box=false;alert(typeof box );
2,UndefinedType
Var box; // undefined type alert (box)
3,NullType
Alert (undefined = null) // undefined is derived from null, so they are equal and return true
4,BooleanType
Var box = true // true is not necessarily 1, false is not necessarily 0. javascript is case sensitive, True is not a boolean value alert (typeof box)
To convert a value to its corresponding boolean value, you can use the Conversion Function Boolean (), which is an explicit conversion and mandatory.
var he = 'hehh'var he2 = Boolean(he)alert(typeof he2)
5,NumberType
Var box = 250; // a decimal integer alert (box); var box = 070; // an octal integer, with a decimal output of 56 alert (box); var box = 3.80; // floating point alert (box); var box = 12.0; // automatically convert alert (box); var box = 4.12e3; // scientific and technological method alert (box ); var box = 0.000000000412; // scientific and technological method alert (box); var box = 100e10000; // exceeds the range alert (box); var box = 100e10000; alert (isFinite (box); // checks whether the isFinite function is out of the range. false or true/* NaN is returned, that is, a non-value (Not aNumber) is a special value, this value indicates a situation where the operand that originally returns a value does not return a value (so that no error is reported ). * /// Var box = 0/0; // NaN // alert (Number. naN) // use Number. naN gets the NaN value // alert (NaN + 1) // the result of any operation with NaN is NaN // alert (NaN = NaN) // NaN is not equal to itself (NaN is not equal to any value)/* The isNaN () function is used to determine whether the value is NaN. After the isNaN function receives a value, it will try to convert it to a value * // alert (isNaN (NaN) // true // alert (isNaN (25 )) // false/* There are three functions that convert non-numeric values to numeric values: Number (), parseInt (), and parseFloat (). Number () is applicable to any type, and the last two are used to convert a string to a numeric value. * /// Alert (Number (true); // values of the boolean Type true and false are converted to 1 and 0, respectively. // alert (Number (25 )); // 25, return directly for numeric type // alert (Number (null); // 0, return 0 for null objects // alert (Number (undefined); // NaN, undefined returns NaN // alert (parseInt ('456lee '); // 456, returns the integer part // alert (parseInt ('lee456lee') // NaN, if the first value is not a value, NaN // alert (parseInt ('12lee34lee ') // 12 is returned, starting from the first value, to the last continuous value // alert (parseInt ('12. 34 ') // 12, the decimal point is not a numerical value, remove // alert (parseInt ('') // NaN, null return NaNparseFloat () is used The usage of floating-point numeric conversion is the same as that of parseInt (). It is resolved from the first digit to the position of a non-floating-point numeric value. It only recognizes one decimal point and converts scientific notation to a common value.
6,StringType
Escape characters of the String type.
Var box = 11; var box = true; the alert (typeofbox. toString (); // string, toString () method can convert the value to a string. /* The toString () method generally does not need to pass parameters, but when the value is converted to a string, you can pass the hexadecimal parameter */var box = 10; alert (box. toString (); // 10, default decimal output alert (box. toString (2); // 1010, binary output
7,ObjectType
// Var box = newObject (); // create by executing the new operator followed by the name of the object type to be created. /* Any parameter can be transmitted in Object (). Values, strings, and boolean values can also be passed. * // var box = newObject (2 ); // value 2 // var age = box + 2; // operation // alert (age); // convert to number type value
You can also use the new operator to create other types of objects. (NewString ('xu '), new Boolean (true ))