Javascript String lastIndexOf(c, lim=this.length)
String.prototype.lastIndexOf = function(c, lim=this.length){ const reg = new RegExp(c) var match = -1// ww w.jav a 2 s. com for (var i=0; i<this.length; i++){ const check = this.slice(i).match(reg) if (check) { check.index <= lim ? match = check.index : undefined } else { break } } return match == -1 ? match : match+i-1 };