Get the string first by calling the toString() method with a base number that is 8 in this case
Number(010).toString(8);
it also works without wrapping in Number,
010.toString(8); //outputs "10"
use this method for padd 0 if you know the length of the original number
function pad(n,digits){return n<Math.pow(10, digits) ? '0'+n : n}
So
pad(Number(010).toString(8),3);
source share