fix: String.lastIndexOf's offset argument must default to the string's length
This commit is contained in:
parent
7058a689a2
commit
12cff84666
@ -41,8 +41,9 @@ export const String = (() => {
|
|||||||
offset = +offset;
|
offset = +offset;
|
||||||
return string.indexOf(self, search, offset, false);
|
return string.indexOf(self, search, offset, false);
|
||||||
}
|
}
|
||||||
public lastIndexOf(search: string, offset = 0) {
|
public lastIndexOf(search: string, offset?: number) {
|
||||||
const self = unwrapThis(this, "string", String, "String.prototype.lastIndexOf");
|
const self = unwrapThis(this, "string", String, "String.prototype.lastIndexOf");
|
||||||
|
if (offset == null) offset = self.length;
|
||||||
offset = +offset;
|
offset = +offset;
|
||||||
return string.indexOf(self, search, offset, true);
|
return string.indexOf(self, search, offset, true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user