JavaScript Program to Convert Binary to Octal
Vikas
2 min readOct 29, 2026
In JavaScript, converting a binary number to an octal number is a common programming problem for beginners. Binary numbers use only two digits, 0 and 1, while octal numbers use digits from 0 to 7.
JavaScript provides built-in methods such as parseInt() and toString() to convert numbers between different number systems.
In this article, we will learn different methods to convert a binary number to an octal number in JavaScript with examples.
What Is Binary to Octal Conversion?
Binary number system: The binary number system has a base of 2 and uses only the digits 0 and 1.
Octal number system: The octal number system has a base of 8 and uses digits from 0 to 7.
For example:
Binary number: 110101
Decimal equivalent: 53
Octal equivalent: 65
Therefore, the binary number 110101 is equal to the octal number 65.
Problem Statement
Given a binary number as a string, convert it into its equivalent octal number using…