This question already has an answer here: How to check for ... The best way is to check the type, because undefined / null / false are a tricky thing ...
stackoverflow.com