String.prototype.at = function(str) {
var tl = this.length, sl = str.length;
for(var i=j=0; i<tl; i++) {
if(this[i] == str[j] && sl == ++j && sl != i) return ++i-j;
}
return -1;
}
var s1 = 'aabac', l1 = 'abac';
alert([
[s1.at(l1), s1.indexOf(l1)]
].join('\n'));