Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2006
    Thanked 0 Times in 0 Posts

    The Array.splice() Method

    If I get it right, the splice method only works if all of the indexes in the array are numerical values? (i.e. 0, 1, 2, 3, ...)

    I tried using it when the indexes were strings, not numbers - and it didn't work:

    var x = new Array();
    x['one'] = 'a;
    x['two'] = 'b';
    x['three'] = 'c';
    x['four'] = 'd';

    x.splice('two', 1);

    for (i in x)
    document.write(x[i] + '<br />');

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    the U.S. of freakin' A.
    Thanked 158 Times in 149 Posts
    Definition and Usage
    The splice() method is used to remove and add new elements to an array.


    1) index - Required. Specify where to add/remove elements. Must be a number
    2) howmany - Required Specify how many elements should be removed. Must be a number, but can be "0"
    3) element1 - Optional. Specify a new element to add to the array
    4) elementX - Optional. Several elements can be added
    Last edited by chump2877; 05-04-2007 at 05:01 PM.
    Regards, R.J.


    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :-)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪


    Posting Permissions

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