Can you use x === "object" to test if x is an object?

Submitted by: Administrator
In short, yes, but you must take into account the fact that null is considered an object in JavaScript. Even if x is null, 'console.log(typeof x === "object")' will log true instead of false.
To account for this, you must also test whether or not x is null by including the following:
console.log((x !== null) && (typeof x === "object"));
Submitted by:

Read Online Expert Developer JavaScript Job Interview Questions And Answers