1, the first kind of typeof
Console.log (typeof undefined)//' undefined '
Console.log (typeof null)//well-known bug
Console.log (typeof True)//' Boolean '
Console.log (typeof 123)//' number '
Console.log (typeof "ABC")//' string '
Console.log (typeof function () {})//' function '
Console.log (typeof {})//' object '
Console.log (typeof [])//' object '
typeof there is a problem with the use of the TypeOf operator when using a reference type to store values there is a problem, regardless of what type of object is referenced, it returns "Object".
2, the second kind of tosring.call
Console.log (Tostring.call (123))//[object number]
Console.log (Tostring.call (' 123 '))//[object String]
Console.log (Tostring.call (undefined))//[object undefined]
Console.log (Tostring.call (True))//[object Boolean]
Console.log (Tostring.call ({}))//[object object]
Console.log (Tostring.call ([]))//[object Array]
Console.log (Tostring.call () (function () {}))//[object function]
3. The third type of instanceof
Console.log (arr instanceof Array)//true
Console.log (date instanceof date)//true
Console.log (FN instanceof Function)//True
4. Fourth Type Constructer
Console.log (Arr.constructor = = = Array)//True
Console.log (Date.constructor = = = date)//True
Console.log (Fn.constructor = = Function)//True
5. Fifth method of jquery
jquery provides a series of tool methods to determine the data type to compensate for the lack of native typeof operators for JavaScript.
The following method determines the parameters and returns a Boolean value.
Jquery.isarray (): is an array.
Jquery.isemptyobject (): Is an empty object (with no enumerable properties).
Jquery.isfunction (): is a function.
Jquery.isnumeric (): is a number.
Jquery.isplainobject (): Is the object that was generated using "{}" or "new object" instead of the object provided by the native browser.
Jquery.iswindow (): Is the Window object.
Jquery.isxmldoc (): Determines whether a DOM node is in an XML document.
How to tell the data type