The octal notation

The octal notation is a number system where we use only eight digits, that is, from 0 to 7. You can represent a number in octal format with JavaScript if you like.

Earlier, to represent a numeric constant as octal, we needed to prefix the numeric constant using 0. For example, take a look at the following:

const a = 017;const b = 15;console.log(a === b);console.log(a);

The output is as follows:

true15

But often, programmers new to JavaScript, get confused with octal representations and decimal numbers with 0 at the front. For example, they think 017 is the same as 17. Therefore, to remove this confusion, JavaScript now allows us to prefix numeric constants using 00 to make JavaScript interpret them as octal. Here is an ...

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.