Checks whether a JavaScript valis is of a certain type