问题
I feel uncomfortable asking, but how do I convert an array of words to make a sentence ?
I keep finding the other way round.
Something like:
var a = ['hello', 'world'];
and obtain :
hello world
回答1:
This doesn't need jquery. Javascript has a very simple way of doing this with the join function:
a.join(" ");
回答2:
Just join the elements of the array into a string using a space as a separator:
var sentence = a.join(" ");
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/join
回答3:
Do you mean something like?
arr.join(" ");
来源:https://stackoverflow.com/questions/7513129/how-to-convert-array-of-words-to-make-a-sentence