Skip to content

Commit

Permalink
Merge pull request denysdovhan#40 from MapleGu/patch-1
Browse files Browse the repository at this point in the history
ECMAScript 5 specifies that 10 (decimal) is used
  • Loading branch information
denysdovhan authored Aug 8, 2017
2 parents 942ea5d + d94bbe9 commit 3f91c21
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,12 @@ Don't forget about octals:

```js
parseInt('06'); // 6
parseInt('08'); // 0
parseInt('08'); // 8 if support ECMAScript 5
parseInt('08'); // 0 if not support ECMAScript 5
```

**💡 Explanation:** This is because `parseInt` accepts a second argument for radix. If it is not supplied and the string starts with a `0` it will be parsed as an octal number.
**💡 Explanation:** If the input string begins with "0", radix is eight (octal) or 10 (decimal). Exactly which radix is chosen is implementation-dependent. ECMAScript 5 specifies that 10 (decimal) is used, but not all browsers support this yet. For this reason always specify a radix when using `parseInt`.


## Math with `true` and `false`

Expand Down

0 comments on commit 3f91c21

Please sign in to comment.