Checks whether a JavaScript value is of a certain type