I see this article but it's specific to deleting a character if it's a certain number (0, in that case).
I want to remove the first character from a string no matter what it is.
splice()
and shift()
won't work because they're specific to arrays:
let string = "stake";
string.splice(0, 1);
console.log(string);
let string = "stake";
string.shift();
console.log(string);
slice()
gets the first character but it doesn't remove it from the original string.
let string = "stake";
string.slice(0, 2);
console.log(string);
Is there any other method out there that will remove the first element from a string?
Use substring
let str = "stake";
str = str.substring(1);
console.log(str);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With