add after ary assign assignIn assignInWith assignWith at before bind bindAll bindKey camelCase capitalize castArray ceil chain chunk clamp clone cloneDeep cloneDeepWith cloneWith compact concat conformsTo countBy create curry curryRight debounce deburr defaults defaultsDeep defer delay difference divide drop dropRight each eachRight endsWith entries entriesIn eq escape every extend extendWith fill filter find findIndex findKey findLast findLastIndex findLastKey first flatMap flatMapDeep flatMapDepth flatten flattenDeep flattenDepth flip floor forEach forEachRight forIn forInRight forOwn forOwnRight fromPairs functions functionsIn get groupBy gt gte has hasIn head inRange includes indexOf initial intersection invert invertBy invoke invokeMap isArguments isArray isArrayBuffer isArrayLike isArrayLikeObject isBoolean isBuffer isDate isElement isEmpty isEqual isEqualWith isError isFinite isFunction isInteger isLength isMap isMatch isMatchWith isNaN isNative isNil isNull isNumber isObject isObjectLike isPlainObject isRegExp isSafeInteger isSet isString isSymbol isTypedArray isUndefined isWeakMap isWeakSet join kebabCase keyBy keys keysIn last lastIndexOf lowerCase lowerFirst lt lte map mapKeys mapValues max maxBy mean meanBy memoize merge mergeWith min minBy multiply negate nth omit omitBy once orderBy overArgs pad padEnd padStart parseInt partial partialRight partition pick pickBy pull pullAll pullAllBy pullAllWith pullAt random rearg reduce reduceRight reject remove repeat replace rest result reverse round sample sampleSize set setWith shuffle size slice snakeCase some sortBy sortedIndex sortedIndexOf sortedLastIndex sortedLastIndexOf sortedUniq split spread startCase startsWith subtract sum sumBy tail take takeRight tap template throttle thru toArray toFinite toInteger toLength toLower toNumber toPairs toPairsIn toPlainObject toSafeInteger toString toUpper transform trim trimEnd trimStart truncate unary unescape union uniq uniqBy uniqWith unset unzip unzipWith update updateWith upperCase upperFirst values valuesIn without words wrap wrapperAt wrapperChain wrapperCommit wrapperFlatMap wrapperLodash wrapperNext wrapperPlant wrapperReverse wrapperToIterator wrapperValue xor zip zipObject zipObjectDeep zipWith

Lodash _.pull

Overview

The lodash _.pull method is a convenient tool for removing all instances of a given value from an array. This method works by iterating through an input array, checking each value to see if it matches a specified target value, and removing all matches as needed.

The _.pull method takes two parameters: the array to modify as the first parameter, and the value(s) to remove from the array as one or more additional parameters. This method modifies the input array in place and returns the modified array for convenience.

Here is an example of using _.pull to remove all instances of a value from an array:

const array = ['apple', 'banana', 'cherry', 'banana', 'date'];
_.pull(array, 'banana');
console.log(array); // Output: ['apple', 'cherry', 'date']

In this example, _.pull is used to remove all instances of the string 'banana' from the array variable. The resulting array only contains the values ['apple', 'cherry', 'date'].

The _.pull method also supports removing multiple values at once:

const array = ['apple', 'banana', 'cherry', 'banana', 'date'];
_.pull(array, 'banana', 'cherry');
console.log(array); // Output: ['apple', 'date']

In this example, both the string values 'banana' and 'cherry' are removed from the array variable with a single call to _.pull.

It is important to note that _.pull removes all instances of the specified value(s) from the array. If you only want to remove the first instance of a value, you can use the _.remove method instead.

Overall, the lodash _.pull method is a useful tool for modifying arrays by removing specific values efficiently and conveniently.