Javascript Array detect Arrays
let myArrayFromConstructor = new Array("hello", "world"); let myArrayFromLiteral = ["hello", "world"]; console.log( typeof myArrayFromConstructor); console.log( typeof myArrayFromLiteral); function isArray(obj) {// ww w . j av a2s .co m return Object.prototype.toString.apply(obj) === '[object Array]'; } console.log( isArray(myArrayFromLiteral) ); console.log( isArray(myArrayFromConstructor) ); </script> </body> </html>