locutus
Version:
Locutus other languages' standard libraries to JavaScript for fun and educational purposes
14 lines (13 loc) • 459 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Index = Index;
function Index(s, sep) {
// discuss at: https://locutus.io/golang/strings/Index
// parity verified: Go 1.23
// original by: Kevin van Zonneveld (https://kvz.io)
// example 1: Index('Kevin', 'K')
// returns 1: 0
// example 2: Index('Kevin', 'Z')
// returns 2: -1
return (s + '').indexOf(sep);
}