Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript remove leading zeros from string

use a regular expression like this  

var strNumber = "0049";  
console.log(typeof strNumber); //string  
  
var number  = strNumber.replace(/^0+/, ''); 
Comment

PREVIOUS NEXT
Code Example
Javascript :: number with commas js 
Javascript :: 1 line uuid 
Javascript :: node console log without newline 
Javascript :: discord.js all intents 
Javascript :: socket io cdn 
Javascript :: emmet not working react js 
Javascript :: js timer reload page 
Javascript :: jquery on body click 
Javascript :: showing difference between dates in minutes js 
Javascript :: how to know connected internet in js 
Javascript :: history back js 
Javascript :: npx create-react-app 
Javascript :: javascript throw vs console.error 
Javascript :: integer to roman javascript 
Javascript :: function to generate random color in javascript 
Javascript :: jquery disable class attribute 
Javascript :: alphabets regex js 
Javascript :: set port in react app 
Javascript :: jquery stoppropagation 
Javascript :: how to pass laravel route name to ajax request 
Javascript :: pass csrf token in ajax laravel 
Javascript :: uppercase string in js 
Javascript :: how to change background image using javascript 
Javascript :: filter array with unique objects javascript 
Javascript :: disable input field from jquery 
Javascript :: javascript regex match any character including newline 
Javascript :: javascript find shortest word in string 
Javascript :: remove last char from string javascript 
Javascript :: settimeout node js 
Javascript :: set value in span using jquery 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =