]> git.proxmox.com Git - pve-eslint.git/blob - eslint/docs/src/rules/no-octal.md
2c961a4386a6023afd82fcbb4792d91c499cd308
[pve-eslint.git] / eslint / docs / src / rules / no-octal.md
1 ---
2 title: no-octal
3 layout: doc
4 rule_type: suggestion
5 ---
6
7
8
9 Octal literals are numerals that begin with a leading zero, such as:
10
11 ```js
12 var num = 071; // 57
13 ```
14
15 Because the leading zero which identifies an octal literal has been a source of confusion and error in JavaScript code, ECMAScript 5 deprecates the use of octal numeric literals.
16
17 ## Rule Details
18
19 The rule disallows octal literals.
20
21 If ESLint parses code in strict mode, the parser (instead of this rule) reports the error.
22
23 Examples of **incorrect** code for this rule:
24
25 ::: incorrect
26
27 ```js
28 /*eslint no-octal: "error"*/
29
30 var num = 071;
31 var result = 5 + 07;
32 ```
33
34 :::
35
36 Examples of **correct** code for this rule:
37
38 ::: correct
39
40 ```js
41 /*eslint no-octal: "error"*/
42
43 var num = "071";
44 ```
45
46 :::
47
48 ## Compatibility
49
50 * **JSHint**: W115