A brief bit on exponents.
2 to the power of four is written in programming as:
2^4
And 2^4 power is 2 times itself four times:
2^4 = 2 × 2 × 2 × 2 = 16
An exponent of 1 is equal to the number itself, so 2^1 is equal to 2
An exponent of 0 is equal to 1, so 2^0 is equal to 1
There's more to exponents, but for the purposes of this article on programming, that is enough.
A brief bit about using a base 2 number system.
Computers store data in memory using a base 2 number system, or binary, a 0 or a 1.
Base 10 number systems counts from 0 to 9 and increments a position when a number greater than 9 is reached. So 8 + 1 = 9, but 9 + 1 causes the adjacent position, the 'tens' position, to increment. So 9 + 1 = 10 and the single digit position must increment again before the tens position increments.
So 10 + 9 = 19 and the tens position does not increment, but once another single digit is added, the tens position increments. That is, 19 + 1 = 20.
Base 2 number systems - hereafter called binary - only count to 1 before incrementing the adjacent position. So the first position is 0 or 1. Let's say the first position is 1 and we add a 1 to it, the adjacent position gets incremented and becomes 10 which represents 2 in the base ten number system.
Here are some binary numbers, their exponential equivalents as well as their base 10 equivalent.
| Binary | Exponent | Base 10 |
| 00000000 | 0 | 0 |
| 00000001 | 2^0 | 1 |
| 00000010 | 2^1 | 2 |
| 00000100 | 2^2 | 4 |
| 00001000 | 2^3 | 8 |
| 00010000 | 2^4 | 16 |
| 00100000 | 2^5 | 32 |
| 01000000 | 2^6 | 64 |
| 10000000 | 2^7 | 128 |
| Add them all up | ||
| 11111111 | 255 | |
A template for converting a binary number to base 10:

An example of converting 10010110:

In a binary system, a 0 or 1 is called a "bit". Eight bits is called a "byte".
An 8-bit quantity or a byte can hold values from 00000000 to 11111111 in binary and 0 to 255 in base ten.
Knowledge of binary is not really necessary at the lower levels of programming, but really comes into play if you're using bitwise operators, understanding memory in computers. It's also helpful in understanding how different base number systems like base 16 is used in html color codes and how basic ascii characters are represented in binary. and that can lead to an understanding of unicode.
Probably the most important understanding to have about binary is the loss of precision that can occur when converting between binary and decimal.
Most decimal fractions cannot be represented exactly as binary fractions.
For example, 1/3 can be written as .3 in base 10 or .33 or .333 and so on as it repeats endlessly.
Convert .3 to binary is 0.01001100110011001101
Convert 0.01001100110011001101 back to base 10 is 0.30000019073486328125
This leads to some strange results.
console.log(.2 + .1)
0.30000000000000004
This is because there is no way to map 0.1 to a finite binary floating point number.
console.log(parseFloat(.2+.1).toPrecision(12));
0.300000000000
The 0.300000000000 returned from toPrecision is actually a type "string". You can see this when a strict equals operator === is used:
console.log((.2+.1).toPrecision(12) === 0.300000000000);
false
console.log(typeof (.2+.1).toPrecision(12));
string
But at the same time, passing the results of toPrecision to the "is not a number" function (isNaN) returns false, meaning it is a number.
console.log(isNaN((.2+.1).toPrecision(12)));
false
That is because isNaN forces a type coercion before evaluating whether or not it is a number.
The same type coercion happens when using "truthy" operator (== instead of ===) and results in the expected outcome:
console.log((.2+.1).toPrecision(12) == 0.300000000000);
true
More strategies for handling precision issues in Javascript here.
Convert binary to decimal calculator.
Using exponents to represent fractions.