1// inside if else check
2if(Array.isArray(myVarToTest)) {
3 // myVatToTest is an array
4} else {
5 // myVarToTest is not an array
6}
1if (typeof array !== 'undefined' && array.length === 0) {
2 // the array is defined and has no elements
3}
4
1var colors=["red","green","blue"];
2
3if(Array.isArray(colors)){
4 //colors is an array
5}
1if(Object.prototype.toString.call(someVar) === '[object Array]') {
2 alert('Array!');
3}
4