0

So I have a string similar to the following:

var mystring = "aasfeeeffdbals";

and I need to make it an array filled with the individual chars. I know what I can do that with the following method:

var charArray = []
for (var i = 0; i<mystring.length; i++) {
    charArray.push(mystring[i]);
}

QUESTION: My understanding of a string is that it already in essence is an array of characters put together, so might there be a more straight forward way of creating a new array with the characters from the string?

Webeng
  • 7,050
  • 4
  • 31
  • 59

1 Answers1

3

var chars = "aasfeeeffdbals".split(''); will bring you wanted result

meta4
  • 788
  • 1
  • 10
  • 24