How to tell if a variable is not an array is a very basic problem.
1. It is easy to use instanceof to judge
instanceof Array
The disadvantage of this usage is that the array instance defined in the IFRAME cannot be applied. For example, the variable a = [] defined inside a child iframe; If you judge:
instanceof Array
Returns FALSE, and the following result is true. Visible within the iframe window creates its own DOM structure and built-in objects.
instanceof document.getelementsbytagname (' iframe ') [0].contentwindow.array
2. You can call Object.prototype.toString to determine, for example,
function IsArray (val) { return Object.prototype.toString.call (val) = = = ' [Object Array] ';}
3. Array.isarray can be used to determine the following:
function IsArray (val) { return (Array.isarray? Array.isarray (val): Object.prototype.toString.call (val) = = = ' [Object Array] '); }
JavaScript determines whether a variable is not an array