I know how to run a script to generate and pad a number but I do not know how to unpad them. For example, 0008 means that there are 4 padding but the value of the padded number is 8.
function pad(num, size) {
var s = num + "";
while (s.length < size)
s = "0" + s;
return s;
}
pad(8, 4);
However, how do I unpad them? Let's say I have a 0011 and I want to unpad the numbers to log only 11. Is there a solution for this?If I use the slice method then it will not work if the padded number is 0100 or 1000.