1.typeof operator: The data type used to detect a given variable
Copy Code code as follows:
var message= "some string";
Alert (typeof message); "String"
Alert (typeof (Message)); "String"
Alert (typeof 100); "Number"
The typeof operator may return the following string:
"Undefined", "Boolean", "string", "number", "Object", "function".
An instance of 2.Object has properties and methods:
constructor--saves the function used to create the current object.
hasOwnProperty ("Property name")--detects whether a given property is a property of the current object instance (not in the prototype of the instance).
isPrototypeOf (object name)--detects if an incoming object is a prototype of another object
ToString ()--Returns the string representation of an object
valueof ()--returns different original values based on different objects, and usually returns the same result as ToString
3. Operator
! Logical non
Operand is an object that returns false
The operand is an empty string that returns True
The operand is a non-empty string that returns false
Operand is a number 0, returns True
The operand is any character (including infinty) that is not 0, and returns false
The operand is null and returns True
Operand is NaN, returns true
Operand is undefined, returns true
* Multiplication
One operand is Nan, and the result is Nan
Infinity * 0 = NaN
Infinity * Non 0 = Infinity or-infinity
Infinity * Infinity = Infinity
/Division
0/0 = NaN
Non-0/0 = Infinity or-infinity
= = = Equal = =: congruent
Equality: first converts to the same type of value in the comparison
Congruent: Must be of the same type and equal in value
4. Type detection
Basic type with valueof
Copy Code code as follows:
var s = "ILoveYou";
var B = true;
var i = 10;
var u;
var n = null;
var o = new Object ();
Alert (typeof s); String
Alert (typeof i); Number
Alert (typeof B); Boolean
alert (typeof u); Undefined
Alert (typeof N); Object
Alert (typeof O); Object
Reference type with instanceof (return True or FALSE)
Copy Code code as follows:
Alert (person instanceof Object); is the variable person object?
Alert (colors instanceof arrary); Variable colors is array?
Alert (Parttern instanceof Regexp); Parttern is RegExp?