The constructor property of the object will refer to the function. Instead, to check if a variable contains an array, do the following:
if (Object.prototype.toString.call(a)==='[object Array]') alert('Array!');
The proposed workaround a.length will not work 100%, because it is possible to have an object with the length property without an actual array.
source share