jashkenas/underscore

Allow string-to-array conversion in _.toArray()

pcorcoran opened this issue · 3 comments

_.toArray('abc') today throws a TypeError. It would great if it instead returned ['a','b','c']. A simple str.split('') would do.

(I understand the line in the sand regarding string functions. But treating strings as collections is a nice-n-functional thing to allow.)

Thanks!

Nope, sorry. It sounds like you've already read all the tickets discussing supporting strings as arrays of characters, so no need to rehash here.

TypeError is definitely what you want in this case.

@jashkenas Could you please link to any issues that cover why underscore doesn't support strings as arrays of characters? Thanks.

I don't know them off the top of my head, but Github Issues search should be able to help you.

Underscore doesn't support strings as arrays of characters because strings aren't arrays of characters in JavaScript.