I
I
Ilya2015-12-29 22:04:55
JavaScript
Ilya, 2015-12-29 22:04:55

how to split string in js?

There is a line in which a space separates the data. How to process a string so that the first part of the string before the space is assigned to one variable, and the second part to the second variable.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
zugo, 2015-12-29
@ArtMavir

var strings = "это строка".split(' ');
var var1 = strings[0],
      var2 = strings[1];

The obvious answer is obvious.

X
xmoonlight, 2015-12-29
@xmoonlight

split

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question