Javascript array to string by join() method
In this article, we will tell you how to convert an array to a string by join method using javascript. sometimes we need to array into a javascript string. we use to comma, space and pipe sign for the array to string.
Now, in the below following example we will take an array and convert it into a javascript string. here, in the below following example we use to space delimited. so you can follow the below example.
1 2 3 4 5 6 7 8 9 10 11 | <script> var fruit = new Array(); fruit.push("Apple"); fruit.push("Mango"); fruit.push("Watermelon"); fruit.push("Orange"); fruit.push("Cherry"); fruit.push("Grape"); var fruitStr = fruit.join(" "); console.log('Delimited String :- ' + fruitStr); </script> |
Please follow and like us: