I have a simple program like:
var a = {\'a\': 1, \'b\': 2}
console.log(a)
console.log(a instanceof Array)
console.log(a.constructor instanceof Array)
I use the toString method in Object.prototype, This works like a charm in all the cases(Array,null,undefined etc).
var array_var=[1,2];
var dict_var={
'a':'hey',
'b':'hello'
};
console.log(Object.prototype.toString.call(dict_var) === '[object Object]');//returns true
console.log(Object.prototype.toString.call(array_var) === '[object Object]');//returns false
In short the toString method is used to represent the object, for example the toString method for an array returns '[object Array]'