SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    insert function for Array

    Hi there,

    Is there any function for Array such as insert(). Basicaly, I have an array and I need to be able to insert something at a specific index.
    With Regards
    Pman
    http://www.pmansLab.com

  2. #2
    SitePoint Zealot
    Join Date
    Nov 2005
    Posts
    113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use the splice() method
    mozilla js reference

    Extracted from there:
    Code:
    myFish = ["angel", "clown", "mandarin", "surgeon"];
    myFish.splice(2, 0, "drum");
    
    myFish is now ["angel", "clown", "drum", "mandarin", "surgeon"]


Bookmarks

Posting Permissions

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