网站的排名与权重,策划案需要给做网站吗,用dw代码做美食网站,重庆找工作的网站目录
查找字符串中的特定元素 String.indexOf() #xff08;返回索引值#xff09;
截取字符串的一部分 .substring() #xff08;不影响原数组#xff09;#xff08;不允许负值#xff09;
截取字符串的一部分 .slice() #xff08;不影响原数…目录
查找字符串中的特定元素 String.indexOf() 返回索引值
截取字符串的一部分 .substring() 不影响原数组不允许负值
截取字符串的一部分 .slice() 不影响原数组允许负值
字符串的分段 .split() 字符串转数组不影响原数组
字符串是否以什么开头/结尾 .startsWith() .endsWith()
后续会更新
查找字符串中的特定元素 String.indexOf() 返回索引值 String.indexOf(value,start) 起始位start可选
const a Blue Whale;
console.log(a.indexOf(Blue))//0
console.log(a.indexOf());//0
console.log(a.indexOf(,14));//10
//当查找的为空字符时起始位超过字符串本身则返回字符串长度
console.log(a.indexOf(ppop));//-1截取字符串的一部分 .substring() 不影响原数组不允许负值 String.substring(startIndex,endIndex) endIndex可选不写默认为最后取左不取右
const str Mozilla;
console.log(str.substring(1, 3));
//oz
console.log(str.substring(2));
//zilla截取字符串的一部分 .slice() 不影响原数组允许负值 String.slice(startIndex,endIndex) 同上
const str The quick brown fox jumps over the lazy dog.;
console.log(str.slice(31));
//the lazy dog.
console.log(str.slice(4, 19));
//quick brown fox
字符串的分段 .split() 字符串转数组不影响原数组 String.split(value) 返回数组value可选
const str The quick brown fox jumps over the lazy dog.;
const words str.split( );
console.log(words[3]);
//fox
const chars str.split();
console.log(chars[8]);
//k
const strCopy str.split();
console.log(strCopy);
//[The quick brown fox jumps over the lazy dog.]字符串是否以什么开头/结尾 .startsWith() .endsWith() String.startsWith(value,[startIndex]) 返回布尔值不允许负值 String.endsWith(value,[endIndex])
const str1 Saturday night plans;
console.log(str1.startsWith(Sat));
// true
console.log(str1.startsWith(Sat, 3));
// false
console.log(str1.endsWith(plans));
// true
console.log(str1.endsWith(plan, 19));
// true