Comment

Comment by rhn_mk1

"asdf".indexOf("as") is 0

but

"asdf"[0] is NOT "as".

so there can be no expectation that ""[0] is "".

Those two operations are not related to each other. It's more intuitive if you treat .indexOf() as .startOf(). Then "asdf"[0..x] is "as" for x=2, and ""[0..x] is "" for x=0.

parent rhn_mk1 2 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton