定义测试使用的字符串
var text
= "Hello World";
字符串Hello World 字符对应下标
HelloWorld
012345678910
字符串截取
text
.substring(6, 11)
"World"
text
.substr(6, 5)
"World"
字符串查找
text
.indexOf("o")
4
text
.lastIndexOf("o")
7
字符串和数组转换
text
.split(" ")
["Hello", "World"]
["Hello", "World"].join("-")
"Hello-World"
参考 JS截取字符串方法实例
转载请注明原文地址: https://mac.8miu.com/read-489533.html