When you call join
without any argument being passed, ,
(comma) is taken as default and toString
internally calls join
without any argument being passed.
So, pass your own separator.
var str = array.join(' '); //'apple tree'
// separator ---------^
More Related Contents:
- How to get character array from a string?
- Why is [1,2] + [3,4] = “1,23,4” in JavaScript?
- How to check if a string contains text from an array of substrings in JavaScript?
- How to find if an array contains a specific string in JavaScript/jQuery?
- Convert string with commas to array
- How can I split a string into segments of n characters?
- How to sort an array based on the length of each element?
- How to check if a string array contains one string in JavaScript? [duplicate]
- How to convert hex string into a bytes array, and a bytes array in the hex string?
- Convert javascript array to string
- Remove empty strings from array while keeping record Without Loop?
- Replace string in javascript array
- Trying to capitalize the first character in array of strings, why this is not working?
- Remove occurrences of duplicate words in a string
- String split returns an array with more elements than expected (empty elements)
- How can I get a character array from a string?
- javascript – Convert array to string while preserving brackets
- Array data to be filled into a table using JavaScript
- What’s the best way to convert a number to a string in JavaScript?
- How to map more than one property from an array of objects
- How can I create every combination possible for the contents of two arrays?
- Javascript: how to dynamically create nested objects using object names given by an array
- Create an array with random values
- Why are Objects not Iterable in JavaScript?
- How to convert Set to Array?
- Why does Array.apply(null, [args]) act inconsistently when dealing with sparse arrays?
- Convert JavaScript String to be all lowercase
- Zip arrays in JavaScript?
- Getter/setter on javascript array?
- Javascript – Template Strings Don’t Pretty Print Objects