Objectかどうかの判定

jQuery.isPlainObjectみたいなやつ。こんな感じかな

function isObject(obj) {
  return obj instanceof Object && Object.getPrototypeOf(obj) === Object.prototype;
}

console.log(isObject({}));             // true
console.log(isObject({ foo: 'bar' })); // true
console.log(isObject(new Object));     // true
console.log(isObject(Object.create(Object.prototype))); // true
console.log(isObject(Object));     // false
console.log(isObject([]));         // false
console.log(isObject(new Array));  // false
console.log(isObject(Array));      // false
console.log(isObject('hoge'));     // false
console.log(isObject(new String)); // false
console.log(isObject(null));       // false
console.log(isObject(undefined));  // false

var Foo = function() {};
var foo = new Foo();
console.log(isObject(Foo));        // false
console.log(isObject(foo));        // false