string index out of range string index out of range: -1

【string index out of range string index out of range: -1】

string index out of range string index out of range: -1

文章插圖
大家好,小跳來為大家解答以上的問題 。string index out of range: -1,string index out of range這個很多人還不知道,現在讓我們一起來看看吧!
1、字符串越界 lastIndexOf 方法返回 String 對象中子字符串最后出現的位置 。
2、 strObj.lastIndexOf(substring[, startindex])lastIndexOf 方法返回一個整數值 , 指出 String 對象內子字符串的開始位置 。
3、如果沒有找到子字符串,則返回 -1 。
4、 如果 startindex 是負數,則 startindex 被當作零 。
5、如果它比最大字符位置索引還大 , 則它被當作最大的可能索引 。
6、 從右向左執行查找 。
7、否則,該方法和 indexOf 相同 。
8、 下面的示例說明了 lastIndexOf 方法的用法: function lastIndexDemo(str2){var str1 = "BABEBIBOBUBABEBIBOBU"var s = str1.lastIndexOf(str2);return(s);} 。
本文到此分享完畢,希望對大家有所幫助 。