Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > The length property

Reply
Thread Tools

The length property

 
 
LAN MIND
Guest
Posts: n/a
 
      01-24-2008
if (xmlhttp) {
var url = "/jsapi/";
var filters = ['location_id', 'time_id'];
for (var i=0; i<filters.length; i++) {
url += gid(filters[i]).value + '/';
}

I see the length property a lot and I'm confused about how it works.
Here I believe it says: loop through: var i is equal to 0, if i is
less than filters.length then i plus 1.

Does the loop count the number of characters in location and based
upon the value (number) of characters assign a certain url?
 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      01-24-2008
LAN MIND wrote on 24 jan 2008 in comp.lang.javascript:

> if (xmlhttp) {
> var url = "/jsapi/";
> var filters = ['location_id', 'time_id'];
> for (var i=0; i<filters.length; i++) {
> url += gid(filters[i]).value + '/';
> }
>
> I see the length property a lot and I'm confused about how it works.
> Here I believe it says: loop through: var i is equal to 0, if i is
> less than filters.length then i plus 1.


No, with arrays, it returns the highest member number plus one.

var filters = ['location_id', 'time_id'];
alert(filters.length); // 2


this is the same as:

filters = new Array();
filters[0] = 'location_id';
filters[1] = 'time_id';
alert(filters.length); // 2

Read the specs and all shall be revealed.

> Does the loop count the number of characters in location and based
> upon the value (number) of characters assign a certain url?


You better read the specs.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Smart or stupid? Tying textbox length to database column length Dan Manes ASP .Net 1 04-23-2006 10:57 PM
911...Need Help! : Length cannot be less than zero. Parameter name : length manmit.walia@gmail.com ASP .Net 2 01-10-2006 03:29 PM
left(string, length) or right(string, length)? Sam ASP .Net 3 02-17-2005 12:01 PM
System.ArgumentOutOfRangeException: Length cannot be less than zero. Parameter name: length =?Utf-8?B?SG96aQ==?= ASP .Net 1 06-01-2004 11:06 PM
How to get length of string? length() problems Mitchua Perl 5 07-17-2003 12:08 AM



Advertisments