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