Question: I see there are a whole lot of different ways to check the typeof a var in Javascript.

But using the typeof of operator seems pretty simpler than other ways -
e.g.

```
if(typeof someVar == typeof "")

if(typeof someVar == typeof [])

function myFunc() {}

if(typeof someVar == typeof myFunc)

```

Is it even valid or a really bad practice to do that? Why?

Thank you.

Answer: 
`typeof` is perfectly fine to use, but not for general type checking. That's not its purpose.

```
typeof [] == "object"

```

It can only distinguish between `"object"`, `"function"`, `"undefined"` and the primitives `"boolean"`, `"number"` and `"string"`. For more advance type checking, you need to use `instanceof` or more complicated checks.

```
[] instanceof Array // works reliably only if there's a single frame
toString.call([]) == "[object Array]" // always works, but only with some types.

```
If you need to check if both the values and types are the same you can use the `===` comparison operator; however, if you just need to check the type it would be most appropriate to use `instanceof`.