The length property

L

LAN MIND

if (xmlhttp) {
var url = "/jsapi/";
var filters = ['location_id', 'time_id'];
for (var i=0; i<filters.length; i++) {
url += gid(filters).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?
 
E

Evertjan.

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).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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top