Vue.Js Array Pop


Array Pop function is used to remove the last element from array and it returns that element. Here in this tutorial, we are going to explain how to use native JavaScript Array Pop function remove an element from Array. You can also use our online editor to edit and run the code online.


Vue.Js Array Pop Method Example

You can use JavaScript Array Pop method in Vue.Js 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.pop();	
    }   
   }

});
</script>  

Try it »

Output of above example-

Vue.js Array Pop

Advertisements

Add Comment

📖 Read More