The length property

Discussion in 'Javascript' started by LAN MIND, Jan 24, 2008.

  1. LAN MIND

    LAN MIND Guest

    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?
    LAN MIND, Jan 24, 2008
    #1
    1. Advertising

  2. LAN MIND

    Evertjan. Guest

    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.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Jan 24, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mitchua
    Replies:
    5
    Views:
    2,712
    Eric J. Roode
    Jul 17, 2003
  2. =?Utf-8?B?SG96aQ==?=
    Replies:
    1
    Views:
    6,933
    Ken Cox [Microsoft MVP]
    Jun 2, 2004
  3. Sam
    Replies:
    3
    Views:
    14,076
    Karl Seguin
    Feb 17, 2005
  4. Replies:
    2
    Views:
    5,907
  5. Dan Manes
    Replies:
    1
    Views:
    721
    David Browne
    Apr 23, 2006
Loading...

Share This Page