-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
js-quirks: Mention annex B.1.1 (legacy octal integer literals).
- Loading branch information
1 parent
53c2f74
commit f60f293
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,23 @@ in this section is easy to deal with, but #4 is special. | |
For another ambiguity, see "Slashes" below. | ||
|
||
|
||
### Legacy octal literals (*) | ||
|
||
This is more funny than difficult. | ||
|
||
In a browser, in non-strict code, every sequence of decimal digits (not | ||
followed by an identifier character) is a *NumericLiteral* token. | ||
|
||
If it starts with `0`, with more digits after, then it's a legacy Annex | ||
B.1.1 literal. If the token contains an `8` or a `9`, it's a decimal | ||
number. Otherwise, hilariously, it's octal. | ||
|
||
``` | ||
js> [067, 068, 069, 070] | ||
[55, 68, 69, 56] | ||
``` | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jorendorff
Author
Contributor
|
||
|
||
|
||
### Strict mode (*) | ||
|
||
*(entangled with: lazy compilation)* | ||
|
Do you want to mention string literals as well?
'\07' === '\x07'
, but'\08' === '\x008'
since8
is not an octal digit, and'\0'
looks like an octal escape but isn't. But still,'\08'
is considered a legacy octal escape sequence, and is thus disallowed in strict mode, or even in sloppy mode within template literals. Not confusing at all :)