var obj = {};
typeof obj; // returns \"object\"
obj instanceof Object // return true
typeof null // returns \"object\"
null instanceof Object // returns false
instanceof more appealing, however you checked instaceof undefined going throw exception that because the undefined is not any singular type object name, It's may or may not sub method of JavaScript Object. Because undefined that type for null (Null Type).
typeof undefined // return "undefined"
undefined instanceof Object // return False
You should check undefined is instaceof JS object, that give a no it's not the object. It's give a boolean result.