Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

JS has proposals to add those. Unfortunately, the spec team is busier with garbage like private class variables.

The className thing is transitory. `class` was reserved in all non-string contexts previously, but in modern JS, you can add it bare in places like object literal keys. Preact allows you to use `class`, but react is more conservative.



Seems like a weird place to apply conservatism. That is, right after inventing entirely new tokens and grammar. But the keyword semantics SHALL NOT be modified.


Historically, you couldn't use ANY of them as object literal keys without risking problems. I believe it was an oversight.

JS has reserved a really long list of keywords that have been around for a long time.. I've seen this occasionally trip up new JS programmers because the words are special without having any use.

abstract, arguments, await, boolean, break, byte, case, catch, char, class, const, continue, debugger, default, delete, do, double, else, enum, eval, export, extends, false, final, finally, float, for, function, goto, if , implements, import, in, instanceof, int, interface, let, long, native, new, null, package, private, protected, public, return, short, static, super, switch, synchronized, this, throw, throws, transient, true, try, typeof, var, void, volatile, while, with, yield


Well, right, but this is JSX, not JS. The rest of JSX is also illegal in JS.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: