Why can't "?" be used in variable or function names

Hey, I'm new here I'm sorry if I'm stepping on any rules.

Just have a dumb question, why can't the question mark character be used in JS as a variable or function name? I understand that there use for "?" as the ternary operator. However adding a question mark to a function or variable would add a lot of context and help to understand someone's code.

Anyway, thank you for reading!

My wild guess is that question marks are not allowed in identifiers for the simple reason that it is uncommon among programming languages to allow punctuation marks in identifiers.

There is probably no chance for adding support of question marks in identifiers, because it would be difficult (impossible?) to maintain BC while keeping a provably unambiguous grammar or a reasonably efficient parser: a? - b : c should continue to be parsed as a ? -b : c.

But question marks are not required to “add context”: you can use another convention, for example prefixing the name with is_.

It isn't because no-one proposed it.
If proposed, it would introduce an ambiguity with the ternary ( ? : ) operator.

E.g., what does



Is it the same as

f ? g?h : i;  // ternary operator where `g?h` is a single ident

or with semicolon insertion the same as

g?h : i;  // a labelled statement

Picking either interpretation would require a lot of parse-ahead or context-sensitivity in the lexer.