If typeof yourVariable === 'object', it's an object or null. If you want to exclude null, just make it typeof yourVariable === 'object' && yourVariable !== null.
Is there a better way to get the type of a variable in JS than typeof? It works fine when you do:
> typeof 1
"number"
> typeof "hello"
"string"
But it's useless when you try:
> typeof [1,2]
"object"
>r = …