#ActuallyAutistic web dev. Does front of the front-end. Loves perf and minimalism. Prefers HTML, CSS, Web Standards over JS, UX over DX. Hates div disease.
You can give position as indexOf second parameter. This gives a plausible little case where you can figure out the length of a string without using length:
'abc'.indexOf('',Infinity)
Most likely useful use case I can think of would be when doing code golfing.
Other than that, I think the current functionality is perfectly fine. It is often a silly case, but I don't see a reason to block it. It does give a valid match to positions between and around characters.
Interesting idea using it to find out the length though that trick only works for JavaScript. In C#, you get an ArgumentOutOfRangeException unless you specify the start position to be within the length of the string.
I'm not sure how useful it would be for finding the position between characters as it can only tell you what the start position was.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You can give position as
indexOf
second parameter. This gives a plausible little case where you can figure out the length of a string without usinglength
:Most likely useful use case I can think of would be when doing code golfing.
Other than that, I think the current functionality is perfectly fine. It is often a silly case, but I don't see a reason to block it. It does give a valid match to positions between and around characters.
Interesting idea using it to find out the length though that trick only works for JavaScript. In C#, you get an
ArgumentOutOfRangeException
unless you specify the start position to be within the length of the string.I'm not sure how useful it would be for finding the position between characters as it can only tell you what the start position was.