Skip to content

Commit f50ecf8

Browse files
committed
indexOf
1 parent bda8a91 commit f50ecf8

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎原生算法实现/indexOf.js‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
String.prototype._indexof = function (s) {
2+
for (var i = 0; i < this.length - s.length; i++) {
3+
console.log(this.charAt(i), this.substring(i))
4+
if (this.charAt(i) === s.charAt(0) && this.substring(i, s.length) === s) {
5+
return i
6+
}
7+
}
8+
return -1
9+
}

0 commit comments

Comments
 (0)