3 ms·
The if condition is wrong. This is why functions like indexOf should return a tuple of a boolean and an offset instead of encoding "not found" by returning -1.
by gizmo 11y ago
The if condition is wrong. This is why functions like indexOf should return a tuple of a boolean and an offset instead of encoding "not found" by returning -1.
- ChristianBundy 11y agoThe if condition should use >= rather than >, but it otherwise makes sense.
- dahart 11y agoI'm not arguing in favor of writing it that way, but I might argue it's not incorrect as written. location.href can never start with an underscore. A regex on location.pathname would sure be a lot clearer to read, though.