1use a regular expression like this
2
3var strNumber = "0049";
4console.log(typeof strNumber); //string
5
6var number = strNumber.replace(/^0+/, '');
11. Using substring()
2The substring() method returns the part of the string between the specified indexes, or to the end of the string.
3
4let str = 'Hello';
5
6str = str.substring(1);
7console.log(str);
8
9/*
10 Output: ello
11*/
12
13The solution can be easily extended to remove first n characters from the string.
14
15
16let str = 'Hello';
17let n = 3;
18
19str = str.substring(n);
20console.log(str);
21
22/*
23 Output: lo
24*/
25
26___________________________________________________________________________
272. Using slice()
28The slice() method extracts the text from a string and returns a new string.
29
30let str = 'Hello';
31
32str = str.slice(1);
33console.log(str);
34
35/*
36 Output: ello
37*/
38
39This can be easily extended to remove first n characters from the string.
40
41
42let str = 'Hello';
43let n = 3;
44
45str = str.slice(n);
46console.log(str);
47
48/*
49 Output: lo
50*/
51
52__________________________________________________________________________
533. Using substr()
54The substr() method returns a portion of the string, starting at the specified index and extending for a given number of characters or till the end of the string.
55
56
57let str = 'Hello';
58
59str = str.substr(1);
60console.log(str);
61
62/*
63 Output: ello
64*/
65
66Note that substr() might get deprecated in future and should be avoided.