Doing it gracefully requires that you say what 'graceful' means in this context. It may or may not mean doing it correctly.
Doing it gracefully requires that you say what 'graceful' means in this context. It may or may not mean doing it correctly.
You want to type check with the actual runtime environment, not just a static guess at it.
I guess by "graceful," not segfaulting would be a good start.
Why? Standards and abstractions are useful.
> But even if it were, there's a bigger problem: static type checking happens too early. The browser can rev and change its APIs after your static type checking is performed.
At that case your program's behaviour may become inconsistent
> You want to type check with the actual runtime environment, not just a static guess at it.
That's not typechecking and there's no guarantee that your program will work with dynamic typing if the API changes.
> I guess by "graceful," not segfaulting would be a good start.
Is runtime type error better? If the type of your value changes and your assumption was false about the type then it can fail anyway with an incorrect function call.