-2

I have a string like 12345 and I need to explode it to [1,2,3,4,5]. Normally, I would use split, but there are no separators in here. I could use substr (getting length, making loops), but I will probably have a lot of those strings, so it may not be good for performance. What can I do?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Tomek Buszewski
  • 7,659
  • 14
  • 67
  • 112

1 Answers1

0

Simply use an empty string as a delimiter:

"12345".split('');
Banana
  • 7,424
  • 3
  • 22
  • 43