I don't understand this behavior of indexOf()
and lastIndexOf()
:
let foo = 'A';
foo.indexOf(''); // 0
foo.lastIndexOf(''); // 1
Based on the indexOf()
result, I'd guess that an empty string is on either side of the character 'A' - but if that were the case, lastIndexOf()
would return 2 instead of 1. What's going on here?