jashkenas/underscore — pull request #1378 by dotDeeka (2013-12-17 21:47:18+00:00)
Title: The way _.indexOf acts if passed a string seems confusing

I was developing and wasn't really thinking too closely about what I was doing but I passed a string to _.indexOf expecting it to delegate to the native String.prototype.indexOf method. When it didn't work correctly I thought about what I was doing a bit and realized it was silly since String.prototype.indexOf is supported in all major browsers.

At first I chalked it up to the fact I was just being dumb. Then I thought about it more and realized that _.indexOf actually does work on strings as long as your only looking for one character.

Example:
_.indexOf('foo', 'o'); // returns 1
_.indexOf('foo', 'oo'); // returns -1

Because of the example above I felt this pull request might make sense. Check to see if a string was passed, if true return the result of the strings .indexOf method else continue with regular execution of _.indexOf.

Does this make sense to anyone else?