Data type judgment mode

A, typeof data type is determined

  

  From the above chart, an array of type Array, object type Object, null types are returned Object, so it should be broken down.

Two, instanceof determines whether a reference to a particular example

  

Three, constructor data type is determined

  

  constructo based on a plurality of types, determining an array of objects when using typeof, regular, time for the object, but when using the constructor can determine the correct type, the above drawback is only available in IE8

四、obj.prototype.toString()

  

  Based on various types of objects, or the call you will need apply.

 

The film Reference: https://www.cnblogs.com/crackedlove/p/10331317.html

Guess you like

Origin www.cnblogs.com/flower-y/p/11442342.html
Recommended