Announcement

Collapse
No announcement yet.

Managing Arrays

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Managing Arrays

    Hi

    I have an efs that dynamically manages some arrays. At some points I want to 'tidy' up the arrays which will involve deleting an element from anywhere in the array and re-sizing it ... so for example if i have an array with 100 elements I might want to delete the 25th element and then resize the array to 99. What is the best way to do this.

    Many Thanks

    Paul

  • #2
    Re: Managing Arrays

    Paul
    You can remove one or more elements using the .splice() method of the Array Object which will also change the length of the array. For example
    var myArray = new Array (1,2,3,4,5,6,7,8,9)
    myArray.splice(3,1)
    the array will now return 1,2,3,5,6,7,8,9 and a length of 8
    You can also set the length of the array using the .length method
    Alex


    Originally posted by paulm
    Hi

    I have an efs that dynamically manages some arrays. At some points I want to 'tidy' up the arrays which will involve deleting an element from anywhere in the array and re-sizing it ... so for example if i have an array with 100 elements I might want to delete the 25th element and then resize the array to 99. What is the best way to do this.

    Many Thanks

    Paul

    Comment

    Working...
    X