EN
TypeScript - remove first character from string
0 points
In TypeScript, it is possible to remove the first character from the string in the following ways.
xxxxxxxxxx
1
const text: string = 'abc';
2
const substring: string = text.slice(1);
3
4
console.log(substring); // bc
Output:
xxxxxxxxxx
1
bc
xxxxxxxxxx
1
const text: string = 'abc';
2
const substring: string = text.substr(1);
3
4
console.log(substring); // bc
Output:
xxxxxxxxxx
1
bc
xxxxxxxxxx
1
const text: string = 'abc';
2
const substring: string = text.replace('abc', 'bc');
3
4
console.log(substring); // bc
Output:
xxxxxxxxxx
1
bc