Vue.js Convert Array to String


We can use Native JavaScript join() method to convert an array to string. Here in this article, we are going to explain how you can use this method to join array. You can also use our online editor to edit and run the code online.


Vue.js Convert Array to String- Array Join Method Example

You can convert an array to string simply as below-

Example:

<div id="app">
	<p>item 1 = {{ item1 }}</p>
	<p>Result = {{result}}</p>

	<button @click="myFunction()">Click Me</button>
</div>
<script>
 new Vue({
el: '#app',
  
  data: { 
	  item1:['12', '10', '9','5', '6', '4'],
	  result:''
  },
  
   methods:{
    myFunction: function () {		
		this.result = this.item1.join();	
    }
	}

});
</script>  

Try it »

Output of above example-

Vue.js Convert Array to string

Advertisements

Add Comment

📖 Read More