Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


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

pcorcoran opened this Issue · 3 comments

3 participants

Patrick Corcoran Jeremy Ashkenas Paul Harper
Patrick Corcoran

_.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.)


Jeremy Ashkenas

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.

Jeremy Ashkenas jashkenas closed this
Paul Harper

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

Jeremy Ashkenas

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.