Array.isarray ()
Used to verify that arrays are not
var a = [Console.log] (typeof a); // Object Console.log (Array.isarray (a)); // true
It can be seen that typeof does not validate the array, although Array.isarray () can verify the array, but IE8 is incompatible
var a = [Object.prototype.toString.call] alert ((a)) // [Object Array]
This method can be compatible with IE8 and the following browsers
typeof
function foo () {} Console.log (typeof foo); // function Console.log (typeofnull// object console.log (typeof undefined); // undefined Console.log (typeof ' a '); // string console.log (typeof 1); // Number
Here null is the basic type, not an object, this is a JS bug. There is also a notable place to watch:
null); // true
Because undefined is derived from null in JS
instanceof
function foo () {} var New foo () instanceof foo); // true
Instanceof is a prototype chain to find, if the display prototype object of function Foo is on the implicit prototype chain of a object, it returns true, otherwise false
The green one is the prototype chain of object A.
JS IsArray, typeof, Instanceof