What's happening here and why?
document.write(0154); // === 108
What's happening here and why?
document.write(0154); // === 108
Numbers that begin with 0 are considered octal (base-8) numbers.
base 8 [0154] = base 10 [108]
but if you had used a number that had an 8 or 9 you wouldn't have seen this problem since that neither 8 nor 9 is an octal digit.
It is printing out the octal equivalent of what you wrote because it started with 0. Try 0001 (prints out 1), 0010 (prints out 8), 0011 (prints out 9)