博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
如何在JavaScript中删除字符串的第一个字符
阅读量:2507 次
发布时间:2019-05-11

本文共 520 字,大约阅读时间需要 1 分钟。

Let’s say you have a string, and you want to remove the first character in it.

假设您有一个字符串,并且想要删除其中的第一个字符。

How can you do so?

你该怎么做?

One easy solution is to use the slice() method, passing 1 as parameter:

一种简单的解决方案是使用slice()方法,将1作为参数传递:

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

Note that the slice() method does not modify the original string.

请注意, slice()方法不会修改原始字符串。

It creates a new string, this is why I assign it to a new variable in the above example.

它创建了一个新字符串,这就是为什么在上面的示例中将其分配给新变量的原因。

翻译自:

转载地址:http://dmmgb.baihongyu.com/

你可能感兴趣的文章
Notes on <High Performance MySQL> -- Ch3: Schema Optimization and Indexing
查看>>
C语言之一般树
查看>>
懂了很多大道理,却依旧过不好一生
查看>>
手工数据结构系列-C语言模拟队列 hdu1276
查看>>
【PyQt5 学习记录】008:改变窗口样式之二
查看>>
android EditText长按屏蔽ActionMode context菜单但保留选择工具功能
查看>>
BUAA 111 圆有点挤
查看>>
c++ 继承产生的名字冲突问题 (1)
查看>>
SQL中on条件与where条件的区别
查看>>
Ubuntu下查看软件版本及安装位置
查看>>
安装IIS
查看>>
动态加载JS(转)
查看>>
SWUST OJ(961)
查看>>
js换空格为别的元素
查看>>
Recommendation Systems
查看>>
shell脚本 inotify + rsync 同步脚本
查看>>
maven pom 引入本地jar包
查看>>
QVT之The Relations Language(Part 二)
查看>>
python--dict和set类型--4
查看>>
快速实现Magento多语言的设置和产品数据的多语言方法
查看>>