JSFiddle - React, Tailwind, and code Playground
by Graham Fairweather
JavaScript
function indexesOf(array, searchElement, fromIndex) {
var result = [],
index = array.indexOf(searchElement, fromIndex >>> 0);
if (index === -1) {
return result;
}
return result.concat(index, indexesOf(array, searchElement, index + 1));
}
function removeFrom(array, searchElement, fromIndex) {
var index = array.indexOf(searchElement, fromIndex >>> 0);
if (index !== -1) {
array.splice(index, 1);
removeFrom(array, searchElement, index);
}
return array;
}
var a = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0];
console.log(indexesOf(a, 0));
console.log(removeFrom(a, 0));