48 lines
1.4 KiB
Plaintext
48 lines
1.4 KiB
Plaintext
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
Additionally, these literals will throw SyntaxError in strict mode. 0-prefixed octal literals have been deprecated since ECMAScript 5 and should not be used in modern JavaScript code.
|
|
|
|
[source,javascript,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
const myNumber = 010; // Noncompliant: Deprecated format
|
|
----
|
|
|
|
Use decimal syntax when possible as it is more readable.
|
|
|
|
[source,javascript,diff-id=1,diff-type=compliant]
|
|
----
|
|
const myNumber = 8;
|
|
----
|
|
|
|
If octal notation is required, use the standard syntax: a leading zero followed by a lowercase or uppercase Latin letter "O" (`0o` or `0O`).
|
|
|
|
[source,javascript,diff-id=1,diff-type=compliant]
|
|
----
|
|
const myNumber = 0o10;
|
|
----
|
|
|
|
== Resources
|
|
=== Documentation
|
|
|
|
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Numbers_and_dates#octal_numbers[Octal numbers]
|
|
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_octal[SyntaxError: "0"-prefixed octal literals are deprecated]
|
|
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode[Strict mode]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|