当前位置:网站首页>JS remove first character of string

JS remove first character of string

2022-06-23 03:18:00 It workers

Suppose you have a string , You want to delete the first character .

If you , How would you solve it ?

A simple solution is to use slice() Method , take 1 Pass as a parameter :

The implementation code is as follows :

const text = 'abcdef'
const editedText = text.slice(1) //'bcdef'

Be careful :slice() Method does not modify the original string .

slice Method will create a new string , This is why I assigned it to a new variable in the above example .

原网站

版权声明
本文为[It workers]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/01/202201211229323026.html