Link to home
Start Free TrialLog in
Avatar of kadin
kadinFlag for United States of America

asked on

How to check length of array?

I expect this to alert the number 0. Instead, nothing is alerted. Is length the wrong command to use to get numbers 0, 1 or 2? Thanks.

var input = Array(3);
input[0] = 'subject';
alert(input.length);
Avatar of Gary
Gary
Flag of Ireland image

Nthing wrong with the code and it should alert 3 since you set the array length to be 3
If you don't set the array length then it will alert 1
Also not advisable to use element names for vars.
Avatar of kadin

ASKER

Thanks for your response.

My code doesn't alert anything.
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kadin

ASKER

I think your right. I have run out of time today. I will work on it tomorrow. Thanks for your help.