2023-05-03 11:06:20 +02:00
== Why is this an issue?
2020-06-30 12:47:33 +02:00
include::../description.adoc[]
2023-07-14 14:02:36 +02:00
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.
2020-06-30 12:47:33 +02:00
2023-08-15 09:43:48 +02:00
[source,javascript,diff-id=1,diff-type=noncompliant]
2020-06-30 12:47:33 +02:00
----
2023-07-14 14:02:36 +02:00
const myNumber = 010; // Noncompliant: Deprecated format
2020-06-30 12:47:33 +02:00
----
2023-07-14 14:02:36 +02:00
Use decimal syntax when possible as it is more readable.
2020-06-30 12:47:33 +02:00
2023-08-15 09:43:48 +02:00
[source,javascript,diff-id=1,diff-type=compliant]
2020-06-30 12:47:33 +02:00
----
2023-07-14 14:02:36 +02:00
const myNumber = 8;
2020-06-30 12:47:33 +02:00
----
2023-07-14 14:02:36 +02:00
If octal notation is required, use the standard syntax: a leading zero followed by a lowercase or uppercase Latin letter "O" (`0o` or `0O`).
2023-08-15 09:43:48 +02:00
[source,javascript,diff-id=1,diff-type=compliant]
2023-07-14 14:02:36 +02:00
----
const myNumber = 0o10;
----
== Resources
=== Documentation
2023-10-19 11:46:59 +02:00
* 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]
2021-06-02 20:44:38 +02:00
2021-06-03 09:05:38 +02:00
ifdef::env-github,rspecator-view[]
2021-09-20 15:38:42 +02:00
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
2021-06-08 15:52:13 +02:00
'''
2021-06-02 20:44:38 +02:00
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
2023-06-22 10:38:01 +02:00
2021-06-03 09:05:38 +02:00
endif::env-github,rspecator-view[]