I just ran into a bit of confusion today, "string".indexOf('');
always returns 0
, but I would expect -1
(for false
); inversely, "string".lastIndexOf('');
always returns 6
lastIndexOf
is easier to understand, since string is 6 letters long ("string".length
, being zero-indexed returns 5
) but I don't see anywhere in the ECMAscript spec (5.1 or 6.0) that describes why ''
would be treated like a word/character boundary
What, exactly, is going on here?