Check if a value is an object in JavaScript
If typeof yourVariable === ‘object’, it’s an object or null. If you want null, arrays or functions to be excluded, just make it: if ( typeof yourVariable === ‘object’ && !Array.isArray(yourVariable) && yourVariable !== null ) { executeSomeCode(); }