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