Analogue rfind in javascript?

Hello. Found one in python, but I don't know. Some crap had transformed all in javascript, like hire. What could have replaced it myself, where it was necessary. Left only one line:

someString.rfind (subStr, 0, -1);

I can not understand how in the end can be -1, because judging by the docks is the final index.. indexOf, lastIndexOf does not always work as in Python. In this, please either suggest what exactly gives -1, or to show a complete analogue of the entire function.

Thanks in advance!)
June 27th 19 at 15:19
1 answer
June 27th 19 at 15:21
Solution
to read the documentation? no, not heard))

start and end is a usual slice. accordingly, end = -1 means remove the last character in the string.
I think so it is clearer ideone.com/HQKb7F
Oh, thank you) Well, there documentation is not very good, like the language itself (IMHO), sorry) - Gerda57 commented on June 27th 19 at 15:24
Oh well)) https://docs.python.org/2/library/string.html#stri...
well, that is. - kavon.Murphy commented on June 27th 19 at 15:27
First heard this interpretation of a negative number in the slice, in the context of the question maybe OK explanation, and in General, if the indices and slices to look odd not) - alexandro_Auer commented on June 27th 19 at 15:30
negative index is a classic, and not only in Python.
ideone.com/R2bUG6 - kavon.Murphy commented on June 27th 19 at 15:33

Find more questions by tags PythonJavaScript