substring函数的正确使用方法
substring函数用于获得字符串的子串,其语法为:substring(startIndex, endIndex),其中startIndex表示子串的起始位置(包括startIndex位置的字符),endIndex表示子串的结束位置(不包括endIndex位置的字符)。
示例:
var str = "Hello World";
var subStr = str.substring(6, 11);
console.log(subStr); // 输出"World"
需要注意的是,如果省略endIndex参数,则子串将包括从startIndex位置到字符串末尾的所有字符。
示例:
var str = "Hello World";
var subStr = str.substring(6);
console.log(subStr); // 输出"World"
tiktok粉丝购买:https://www.smmfensi.com/
TOP