... it could be tested for as an available method without causing older browsers to barf.
How?
It's virtually impossible to test for a keyword, since the browsers that do recognise it will barf if it's used as an identifier anyway. About the only way of doing it is using try/catch with eval(), whose exceptions are not always fatal:
Code:
try {
eval("var final;");
} catch(e) {
// final is reserved (and thus implemented)
}
However, since it's reserved without being implemented in the current state of affairs, we do the test the other way around:
Code:
try {
eval("final myvar;");
} catch(e) {
// We can't define final variables (so final isn't implemented).
}
Bookmarks