I had this code suggested to me:
var activityArray = [];
activityArray.push("Loading content 1");
activityArray.push("Loading content 2");
activityArray.push("Loading content 3");
activityArray.push("Loading content 4");
//find the item we want to delete
var index = activityArray.indexOf('Loading content 4');// returns 3
activityArray.splice(index,1)//remove the item at index 3
I have a lot of places where I want to add elements to my array so "activityArray.push
" seems like a very easy way to do this.
I also have a lot of places where I want to remove the elements from the array. Is there a way that I could take the code to delete the item and add it as a function to activityArray so that I could say:
activityArray.pull("Loading content 4");