This feature is designed to have no impact on the interpretation semantics of numeric literals: _
are to be ignored by interpreters and should have no effect. They are meant exclusively as a visual clue to aid development and have no runtime semantics.
The following grammar represents the Stage 1 criteria, which is:
- No leading or trailing separator.
- No multiple adjacent separator.
- No separator adjacent to decimal point
.
- No separator adjacent to ExponentIndicator.
- No separator adjacent to
0b
,0B
,0o
,0O
,0x
,0X
.
Changes to Numeric Literals shown in rendered proposal.
Changes to ToNumber Applied to the String Type & Runtime Semantics: MV shown in rendered proposal.
Changes to Runtime Semantics: MV shown in rendered proposal.
The Number constructor and Number(value) both rely on ToNumber, so there is no change needed.
The abstract operation ToNumber ( argument ) requires no change since it relies on the BinaryIntegerLiteral, OctalIntegerLiteral, HexIntegerLiteral and DecimalDigits changed above.
The syntax defined in ToNumber Applied to the String Type is adjusted to use the newly defined StrDecimalDigits, preserving the behavior of parseFloat( string ). Runtime Semantics: MV are also updated by replacing DecimalDigits with StrDecimalDigits.
Both rely on ToNumber semantics (18.2.2 and 18.2.3), so they adjust automatically.
parseFloat
semantics are unchanged. The syntax for StrDecimalLiteral is updated to define its own StrDecimalDigits, preserving the behavior of "parseFloat applied to the String type".
parseInt
semantics are unchanged.
All detection methods (isXx
methods) operate on actual number values, such as number literals, so they do not introduce extra conversion / parsing rules. The parseFloat
and parseInt
methods are just convenience aliases over their homonyms in the global object.