Just use split
:
var str = "This is an amazing sentence.";
var words = str.split(" ");
console.log(words);
//["This", "is", "an", "amazing", "sentence."]
and if you need it with a space, why don't you just do that? (use a loop afterwards)
var str = "This is an amazing sentence.";
var words = str.split(" ");
for (var i = 0; i < words.length - 1; i++) {
words[i] += " ";
}
console.log(words);
//["This ", "is ", "an ", "amazing ", "sentence."]
Oh, and sleep well!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…