mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-02 08:35:07 +08:00
* Implement static array lastIndexOf search * Coerce dynamic string-search needles before positions * Handle optional string-search needles with positions
14 lines
286 B
JavaScript
14 lines
286 B
JavaScript
function probe(needle, position) {
|
|
const value = "ababa";
|
|
console.log(
|
|
value.indexOf(needle, position),
|
|
value.includes(needle, position),
|
|
value.startsWith(needle, position),
|
|
value.endsWith(needle, position),
|
|
);
|
|
}
|
|
|
|
probe("ba", 1);
|
|
probe(1, 0);
|
|
probe(undefined, 0);
|