dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: Array Splice - By reference

  1. #1
    Join Date
    Nov 2009
    Posts
    1

    Array Splice - By reference

    I understand that Arrays are passed to functions by reference, which is what I want...However the function below returns nothing when called for routes1
    unless I uncomment the line routePoints1 = routes0a when I think it should be set to routes0a after the splice. routes0 is set as it is supposed to be and they are both Global.

    spliceRoute(routePoints, routePoints1);


    function spliceRoute(routes0, routes0a) {
    var r0 = routes0.length;
    var r0a = (r0 - 24);
    if (routes0.length > 24) {
    routes0a = routes0.splice(24, r0a);
    //routePoints1 = routes0a;
    alert(routePoints);
    alert(routePoints1);
    }
    }

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Confusing. Can you re-form and detail your aim, pleae?

  3. #3
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    splice returns the elements you deleted; is that what you want?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles