Asked 7 years ago
8 Mar 2017
Views 1276
lain

lain posted

how to convert string to array in JavaScript ?


var s ='Hello world';

need array like so string divide from space.
so s become array like this

s["Hello","world"]


so let me know better solution
Phpworker

Phpworker
answered Nov 30 '-1 00:00

use split function to split String to Array


var s="Hello World";
s=s.split(" ");
console.log(s);

Post Answer