There is a line:

var s = "строка"; 

You need to get an array of characters from this string:

 'с' 'т' 'р' 'о' 'к' 'а' 

How to do it?

  • why get exactly the array? - Grundy
  • For the odds, I’ll overwrite the text, set the timer and animate it beautifully - pavel1787mego
  • to access by index the string does not need to be translated into an array - it allows you to access a specific character - Grundy

3 answers 3

The split () method splits a string in the specified selector.

 var s = "строка", //Укажем пустую строку чтобы разбить по символам arr = s.split(''); console.log(arr); 

  • Thanks, I'll check it out now! - pavel1787mego
  • Thank you very much, everything works! - pavel1787mego

In ES2015, you can Array.from()

 console.log(Array.from("строка")) 

    It is possible through RegExp:

     var s = "строка", arr = s.match(/./g); console.log(arr);