how can I get the number of elements in an array

Code JavaScript:
function get_active_link(myul, myclass, menuItems){
var menu_unidades_yolo = document.getElementById(myul);
menu_unidades_yolo = menu_unidades_yolo.getElementsByTagName('a');
var number=0;
var current_url = document.location;
while (number <= menuItems){
if (menu_unidades_yolo[number].href == current_url){
menu_unidades_yolo[number].className = myclass;

In that function one has to specify the number of menu items for the menu that I want to make the changes, but how can I get the number of items that are stored by getElementsByTagName?