Vue JS Get Array Length Or Object Length

Share Me
  •  
  •  
  •  
  • 2
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    2
    Shares

Hello Dev
Welcome back with a new tutorial. If you have no idea about how to get array length in vue js then I hope this is right place for you.Today i will give you short example for vue js about how to get object length.

If you want to work with javascript jquery then you must have to know how get array length by variable. Length there are same way you can get array length in vue js application.

Here, I will give you a very simple example on bellow. So you can understand clearly about how to getting array length or object length in vue js code.

Example:

<!DOCTYPE html>
<html>
<head>
    <title>Vue JS Get Array Length Or Object Length Example - Codingspoint.com</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
</head>
<body>
   
<div id="app">
   
  <ul id="exampleApp">
    <li v-if="myArray.length">Object Length = {{ myArray.length }}</li>
    <li v-for="value in myArray">
      {{ value.category }}
    </li>
  </ul>
  
</div>
  
<script type="text/javascript">
  
    var app = new Vue({
      el: '#app',
      data: {
        myArray: [
          { category: 'Laravel' },
          { category: 'PHP' },
          { category: 'Codeigniter' }
        ]
      }
    })
  
</script>
  
</body>
</html>

Read Also : Laravel nl2br Blade Directive

Output:

Object Length = 3

Laravel

PHP

Codeigniter

I hope it can help you. Also you can follow us on Facebook

About Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Shahriar Sagor →

Leave a Reply

Your email address will not be published. Required fields are marked *

2 + 6 =