Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

But "asdf".indexOf("sd") is 1, so indexOf("") finds the index of the first matching subsequence "", thus 0.

In reverse, the function would be 'return the subsequence starting at index, for some length', which for "" and 0 would indeed be "" for length = 0.

Array indexing [] is unrelated



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: