How can % signs be used in identifiers

It is not technically valid JavaScript. These are calls to V8 runtime functions. From that page:

Much of the JavaScript library is implemented in JavaScript code
itself, using a minimal set of C++ runtime functions callable from
JavaScript. Some of these are called using names that start with %,
and using the flag “–allow-natives-syntax”. Others are only called by
code generated by the code generators, and are not visible in JS, even
using the % syntax.

If you look in parser.cc you can see some code relating to allow_natives_syntax that determines whether the parser will accept this extension to the JavaScript language that V8 is using to interact with its runtime. These files must be parsed with that option enabled.

I would speculate that V8 does not allow you to make these calls by default both because it would contradict the JavaScript standard and because it would probably allow you to do things to the runtime you should not be able to do.

Leave a Comment