Count the Number of Items in an Array in JavaScript

You can use length in order to count the number of items in an array in JavaScript:

var array = ["item1","item2",...];
array.length;

For example, you can use the following syntax to count the number of items in the array below:

var items = ["AA","BB","CC","DD","EE"];
items.length;

You’ll then get the count of 5 items using length.

Similarly, you can use this syntax to get a total count for the integers in the array:

var numbers = [2,5,33,22,9,12,45];
numbers.length;

In this case, you’ll get the count of 7 items.

Calculator to Count Number of Items in an Array in JavaScript

Below is a simple calculator that you can use to count the number of items in an Array in JavaScript. Simply enter your items in the entry box. Each item should be separated by a comma:

Array: