How to remove leading zeros from a number in JavaScript?


This content was proof-read by Grammarly. You can Try Grammary for FREE

If you want to remove leading zeros from a number in JavaScript , you can use the parseInt() method.

How to remove leading zeros from a number in JavaScript?

Here’s an example demonstrating how you can use parseInt() function to delete leading zeros.

<!DOCTYPE html>
<html>
   <body>
      <script>
         var number1 = parseInt("034", 10);
         document.write(number1);
      </script>
   </body>
</html>

The output of the above program is

34

Newsletter Signup

Subscribe to our weekly newsletter below and never miss the latest product or an exclusive offer.

Newsletter Signup

Subscribe to our weekly newsletter below and never miss the latest product or an exclusive offer.

%d bloggers like this: