1) Basic Type-number, which adopts the 64-bit floating point format defined by IEEE754 standard. special numeric constant: the special value of Infinity, NaN, is not a numerical value, Number. MAX_VALUE indicates the maximum Number. MIN_VALUE represents the minimum Number. naN non-numeric value Number... syntax
1) Basic Type
--- Number, which adopts the 64-bit floating point format defined by the IEEE754 standard.
Special numeric constants:
Special values of Infinity
NaN non-numeric value
Number. MAX_VALUE indicates the maximum Number.
Number. MIN_VALUE represents the smallest Number.
Number. NaN non-numeric value
Number. POSITIVE_INFINITY positive infinity
Number. NEGATIVE_INFINITY negative infinity
Convert digits into strings in six ways
Var n = 1.23456;
Var n_as_str = n + "";
String (n );
N. toString (x); // x = 2, binary; x = 8, octonay; x = 16, hexadecimal. if empty, decimal
N. toFixed (x); // number of digits after the decimal point
N. toExponential (x); // display the exponential form. x indicates the decimal place.
N. toPrecision (x); // if n-digit> x is displayed as an index, x indicates the precision of the number.
--- String
Convert string to numeric
In the digital environment, it is automatically converted to a number,
Var num = "2" * "3"; // num = 6
Var num = str_val-0;
Var num = Number (str_val); // a Number based on 10 is valid. white spaces at the beginning and end are allowed.
ParseInt (str)
ParseInt (str, radix) // the same with java
ParseFloat (str)
--- Boolean
Explicit conversions
Var x_as_boolean = Boolean (x );
Var x_as_boolean = !! X;
--- Null
Indicates "no value ".
Object conversion: When the Boolean environment is used, the non-null object is false, the string environment is "null", and the numeric environment is 0;
--- Undefined
When an undeclared variable is used, when a declared but not assigned value is used, or when a non-existent object attribute is used
Undefined.
Object conversion: When the Boolean environment is used, the non-null object is false, the string environment is "undefined", and the number environment is NaN;
Difference from null:
Null is the keyword, undefined is not. (ECMAScript v3 defines the undefined global variable, the initial value is undefined)
Null and undefined
Compare null and undefined
Script
Var undef;
Document. write ("Boolean environment :")
Document. write (undef = null); // true
Document. write ("
");
Document. write ("character string environment :")
Document. write ("". undef); // undefined
Document. write ("
");
Document. write ("digital environment :")
Document. write (1 + undef); // NaN
Document. write ("
");
Document. write ("undef === null :")
Document. writeln (undef === null); // false
Document. write ("
");
Document. write ("typeof undef :")
Document. writeln (typeof undef); // undefined
Script
2) composite type
Object: a set of named Data
Object direct quantity: A list consisting of {key: value, *}; (key = identifier/string, value = constant/expression)
Object conversion: When the Boolean environment is used, the non-null object is true; when the string environment is used, toString (); when the number environment is used, valueOf ();
Array
The array element can be an array without holding a multi-dimensional array;
Array elements do not have to have the same type
3) Special Objects
Function
General Syntax: function func_name (args) {func_body ;}
Lambda function, function (args) {func_body ;}
Constructor, new Function ("args", "func_body ");
* Description
After the plan, I will release some sort of notes in the note directory, so you may not be able to remember them as well. This is mainly for your convenience. If you have read it, please advise.
This article is about the javascript data type, mainly from the "javascript authoritative guide ".
From hnyei-WEB Front-end design experience