How Do You Check If A Variable Is An Object

A Variable is an object JAVASCRIPT

You can use typeof to determine if variable is an object, however, bear in mind that null is actually an object! However null object is ‘falsy’ thus the following will work:

if(bar && typeof bar === "object") {
    console.log('bar is object and is not null');
}        

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *