strObj.lastIndexOf(substring[, startindex])
strObj:必選,String 物件或字面值。substring:必選,要查找的子字串。startindex:可選,開始查找的索引位置(預設字串末尾)。indexOf 從左向右)。startindex < 0 視為 0;> 最大索引視為最大索引。function lastIndexDemo(str2) {
var str1 = "BABEBIBOBUBABEBIBOBU";
return str1.lastIndexOf(str2);
}
// lastIndexDemo("BU") → 18 (最後一個 BU 起始位置)