473,394 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

remove a specific element in an array

I have an array with 4 elements
0 house
1 garden
2 table
3 dog

I would remove the third element (that who have index 2)
so to have:
0 house
1 garden
2 dog

code not work
---------------------------------------------
var indxx=0;

for (var ind = 0; ind <array1.length; ind++)
{
if(ind==2)
{ }
else
{
array1[indxx]=array1[ind];
indxx++;
}

}
------------------------------------------

is there a directly command?
is possible to make a cicle that work?
Jun 30 '07 #1
2 1468
found splice;
only pheraphs small problem is compatible from IE 5.5;
so for who have IE 5.1 or IE5.0 not work;
Jun 30 '07 #2
On Jul 1, 5:44 am, artev <mailnotspa...@notspamm.nnwrote:
found splice;
only pheraphs small problem is compatible from IE 5.5;
so for who have IE 5.1 or IE5.0 not work;
If you're concerned about compatibility here is a function that will
do the trick:

<script>
arr = ['house','garden','table','dog'];

Array.prototype.arrayDeleteAt = function(position) {
var arr_new = [];
var arr_len = this.length;
if (arr_len >=0 || arr_len <arr_len) {
for (var i=0; i<arr_len; i++) {
if (i!=position) arr_new.push(this[i]);
}
}
return arr_new;
}

arr = arr.arrayDeleteAt(1);
alert(arr);
</script>

Jul 2 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: koperenkogel | last post by:
Dear cpp-ians, I am working with a vector of structures. vector <meta_segment> meta_segm (2421500); and the structure look like: struct meta_segment { float id; float num;
7
by: Derek Basch | last post by:
I can remove objects from an array by doing this: for (i in oCache){ if (i == "test"){ delete oCache; }; }; However, the array's length property is unaffected.
3
by: Don | last post by:
My user control has a combobox with an arraylist attached to it along with custom add and remove methods. The "Add" method is working great. However I don't understand why the "Remove" method...
3
by: Jeremy | last post by:
I'm trying to parse a sentence and want to remove selected words from the middle. Consider: dim a() as object = split(mySentence) for each w in a() select case w case w.startswith("X")
4
by: eksamor | last post by:
I have a simple linked list: struct element { struct element *next; int start; }; struct list { struct element *head;
3
by: Niyazi | last post by:
Hi all, I have a dataTable that contains nearly 38400 rows. In the dataTable consist of 3 column. column 1 Name: MUHNO column 2 Name: HESNO Column 3 Name: BALANCE Let me give you some...
11
by: Richard Maher | last post by:
Hi, I have read many of the copius entries on the subject of IE performance (or the lack thereof) when populating Select Lists. I don't mind the insert performance so much, (I get 100x120byte...
3
by: Barkingmadscot | last post by:
I am stuck, i can workout how to remove lines from an array I have loading a text file (a Log), I know which lines a need, but the logs can be upto 30K sometimes bigger. I found trying to...
6
by: tedpottel | last post by:
Help How can I remove an item from an array, Example Array=3, array=6 array=7 array=9 Is there a way to remove a item, say index 1, so the array would now be Array=3 array=7 array=9 ?????
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.