1. Using the instanceof operator
2, Array.isarray () (ES5 new method)
3. Use the native ToString () method on Object.prototype to determine.
How to use:
Object.prototype.toString.call (value)
varA={}; varb=[]; varFrame=document.createelement ("iframe");//Create a FrameDocument.body.appendChild (frame); varC=window.frames[0]. Array;//gets the array constructor in the framework global execution Environment varD=NewC ();//Create an array d in the framework Global execution EnvironmentConsole.log (Object.prototype.toString.call (a));//[Object Object]Console.log (Object.prototype.toString.call (b));//[Object Array]Console.log (Object.prototype.toString.call (d));//[Object Array] functionPerson () { This. name=name; } varn=NewPerson (); Console.log (Object.prototype.toString.call (n));//[Object Object]
The method cannot detect the function name of a non-native constructor, so any constructor defined will return [object Object].
Three ways to determine if an object is not an array