MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / remove

Function remove

lib/web/jshint.js:6798–6817  ·  view source on GitHub ↗

* Removes all elements from `array` that `predicate` returns truthy for * and returns an array of the removed elements. The predicate is bound to * `thisArg` and invoked with three arguments: (value, index, array). * * If a property name is provided for `predicate` the created `_

(array, predicate, thisArg)

Source from the content-addressed store, hash-verified

6796 * // => [2, 4]
6797 */
6798 function remove(array, predicate, thisArg) {
6799 var result = [];
6800 if (!(array && array.length)) {
6801 return result;
6802 }
6803 var index = -1,
6804 indexes = [],
6805 length = array.length;
6806
6807 predicate = getCallback(predicate, thisArg, 3);
6808 while (++index < length) {
6809 var value = array[index];
6810 if (predicate(value, index, array)) {
6811 result.push(value);
6812 indexes.push(index);
6813 }
6814 }
6815 basePullAt(array, indexes);
6816 return result;
6817 }
6818
6819 /**
6820 * Gets all but the first element of `array`.

Callers

nothing calls this directly

Calls 3

getCallbackFunction · 0.85
basePullAtFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected