10 examples of 'jquery remove item from array by index' in JavaScript

Every line of 'jquery remove item from array by index' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
98export function remove__index(array, index) {
99 return array.splice(index, 1)
100}
11static remove(array, index, callback) {
12 array.splice(index, 1);
13 if (callback) {
14 callback();
15 }
16}
11export function removeIndexFromArray<a>(array: A, idx: number) {
12 if (idx === -1) return array;
13 return [...array.slice(0, idx), ...array.slice(idx + 1)] as A;
14}</a>
48export function remove(array, index) {
49 var len = array.length - 1;
50
51 var out = new Array(len);
52
53 var i = 0;
54 while (i &lt; index) {
55 out[i] = array[i];
56 ++i;
57 }
58
59 while (i &lt; len) {
60 out[i] = array[i + 1];
61 ++i;
62 }
63
64 return out;
65}
13function arrayRemove (array, el) {
14 let index = array.indexOf(el)
15 if (index &gt; -1) {
16 array.splice(index, 1)
17 }
18 return index
19}
54function remove_element(array, elem) {
55 var index = array.indexOf(elem);
56 if (index &gt; -1) {
57 array.splice(index, 1);
58 }
59}
171function remove(array, el) {
172 var i;
173 for (i = array.length - 1; i &gt; -1; i-=1) {
174 if (array[i] === el) {
175 array.splice(i, 1);
176 }
177 }
178}
483function remove(array, item) {
484 array.splice(array.indexOf(item), 1);
485
486 return array;
487}
536function removeFrom(arr, item){
537 for(var i=0; i
68function remove (arr, item) {
69 if (arr.length) {
70 const index = arr.indexOf(item)
71 if (index &gt; -1) {
72 return arr.splice(index, 1)
73 }
74 }
75}

Related snippets