The difference is that passing the class type as parameter we can check whether the object to return is of the desired type and return a null instead of causing a casting exception. So if you need to be sure that the property in the js object is a boolean  use this method instead of enclose your code in try/catch block