Delete the first character of a string in Javascript

advertisements

I want to delete the first character of a string, if the first character is a 0. The 0 can be there more than once.

Is there a simple function that checks the first character and deletes it if it is 0?

Right now, I'm trying it with the JS slice() function but it is very awkward.


var s = "0000test";
while(s.charAt(0) === '0')
{
 s = s.substr(1);
}

This will kill any 0's at the start of the string.