function isObject(val) { return val != null && typeof val === 'object' && Array.isArray(val) === false; }; True All of the following return true: isObject({}); isObject(Object.create({})); isObject(Object.create(Object.prototype)); isObject(Object.create(null)); isObject({}); isObject(new Foo); isObject(/foo/); False All of the following return false: isObject(); isObject(function () {}); isObject(1); isObject([]); isObject(undefined); isObject(null);
if (!Array.isArray) { Array.isArray = function(arg) { return Object.prototype.toString.call(arg) === '[object Array]'; }; } var arr = new xArray(1,2,3); // [1,2,3] Array.isArray(arr); // true