Comment

Comment by cyrusmg

What's the logic behind returning anything but -1 (not found) ?

Given "asdf".indexOf("a") is 0

Then "asdf"[0] is "a"

--

Given "".indexOf("") is 0

Then ""[0] is "" (which it's not in any language I know of)

parent cyrusmg 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton