The data types in 1.JavaScript include: string, number, Boolean, null, Undefined, Array, object.
The data types in 2.JavaScript can be divided into primitive types and reference types. Where string, number, Boolean, NULL,
Undefined belong to the original type, others are reference types.
3. The easiest thing to judge in a reference type is the method, because the TypeOf directly returns function, and the others are object. So
Reference types other than the judging method need to be judged by instanceof, the instanceof operator is constructed with an object and a
The function is a parameter, and if the object is an instance of the type specified by the constructor, Instanceof returns true;
False The instanceof operator can also be used to identify inherited types. All reference types in JavaScript are inherited from Object
Type, use instanceof to detect the following example:
var items = [];
var object = {};
function reflect (value) {
return value;
}
Console.log (items instanceof Object); True
Console.log (Object instanceof object); True
Console.log (reflect instanceof Object); True
4. Identification array: ECMAScript 5 introduces Array.isarray () to unambiguously identify whether a value is an instance of array, regardless
The value is from where the method returns true for an array from any context.
5. There are 3 types in the original package type (String, number, and Boolean), and the value of these special reference types is to make
Primitive type variables can be used as easily as reference type values (that is, objects), and their presence makes the original type variable callable
Methods to accomplish some common operations. The original type value holds the simple data value, cannot have its own property and method is undoubtedly
In fact, here, the original wrapper types in JavaScript are behind the scenes to help us do a series of work to make our
Ability to call library methods using the original type.
6.console.log (typeof null); "Object", so we cannot use the TypeOf operator to determine whether a variable is
Empty type. The best way to determine whether an empty type is a direct and null comparison, as in the following example:
Value is a variable to determine whether the type is empty
Console.log (value = = null); True or False
http://blog.csdn.net/qq_20974467/article/details/49357269
JavaScript data types