var errors = new Array(); errors['email'] = new Array(); //populate errors array here alert(errors['email'][0]); // <-- output = 'email is invalid' alert(errors['email'].length); // <-- output = 0