The hash size() method is used to calculate the number of items in an array. The code below calculates the number of items in an array and prints it out.
- var myArray = ["a", "b", "c"];
- var size = myArray.length;
- console.log("There are " + size + " items in myArray");
Share a personalized message with your friends.