Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to retain leading zeros in javascript

Tags:

javascript

I have

var x = "0100";

parseInt(x); // returns 100;

Is there a way I can retain the leading 0s and yet convert to number in Javascript

like image 250
user544079 Avatar asked Jul 30 '14 23:07

user544079


Video Answer


1 Answers

No.

Numbers don't have leading zeroes; that's a display issue, not a matter of a number's internal representation.

To display the number with leading zeroes, see here.

like image 130
Robert Harvey Avatar answered Oct 15 '22 01:10

Robert Harvey