Computing.Net > Forums > Web Development > number of entries in array

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

number of entries in array

Reply to Message Icon

Name: raviepic3
Date: October 21, 2008 at 11:22:37 Pacific
OS: Xp
CPU/Ram: 512
Product: new
Comment:

length gives us the overall size of array ryt ?

need to get the number of entries alone from an array

programming newbie :)



Sponsored Link
Ads by Google

Response Number 1
Name: shutat
Date: October 21, 2008 at 19:24:02 Pacific
Reply:

You can instantiate a container of whatever size, but to find out where the valid data is, you'd be better off maintaining an index, and increment or decrement it when you add or remove data.

What language are you using?


0

Response Number 2
Name: raviepic3
Date: October 21, 2008 at 23:39:01 Pacific
Reply:

java script

programming newbie :)


0

Response Number 3
Name: shutat
Date: October 21, 2008 at 23:58:39 Pacific
Reply:

How about

<html><head><script language="javascript1.2">

var arr = new Array();
for(var i=0; i < 5; i++) { arr.push(i); }
alert(arr.length);
arr.pop();
alert(arr.length);

</script></head><body></body></html>

That sort of thing will give you the length of your significant data.

Look into shift and unshift as well as they work on the first element in the array whereas push and pop work on the last element.

HTH


0

Response Number 4
Name: raviepic3
Date: October 22, 2008 at 01:50:43 Pacific
Reply:

thank you brother..

programming newbie :)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: number of entries in array

Get number of words from string www.computing.net/answers/webdevel/get-number-of-words-from-string/3943.html

Updating price list www.computing.net/answers/webdevel/updating-price-list/3031.html

Frontpage Form Guestbook www.computing.net/answers/webdevel/frontpage-form-guestbook/276.html