Lodash _.differenceWith() Method Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Lodash _.differenceWith() method is similar to the _.difference() method that returns the array containing the values that are in the first array not in the second array but in _.differenceWith() all the elements of the first array are compared with the second array by applying comparison provided in third. It may be a little complex to understand by reading this but it will become simple when you see the example. Syntax:_.differenceWith(array, [values], [comparator]);Parameters: array: This parameter holds the array that values are checked or inspected.values: This parameter holds the value that needs to be removed.comparator: This parameter holds the comparison invoked per element.Return Value: This method returns an array according to the condition explained above. Example 1: In this example, we are finding the difference of the arrays by using the lodash _.differenceWith() method. javascript const _ = require('lodash') let x = [1, 2, 3] let y = [2, 4, 5] let result = _.differenceWith(x, y, _.isEqual); console.log(result); Output:[1, 3]Example 2: In this example, we are finding the difference of the arrays by using the lodash _.differenceWith() method. javascript const _ = require('lodash'); let x = [{ a: 1 }, { b: 2 }, 6] let y = [{ a: 1 }, 7, 6] let result = _.differenceWith(x, y, _.isEqual); console.log(result); Output:[{b: 2}]Example 3: In this example, we are finding the difference of the arrays by using the lodash _.differenceWith() method. javascript const _ = require('lodash'); let x1 = [1, 2, 3] let y1 = [2, 4, 5] let result1 = _.differenceWith(x1, y1, _.isEqual); console.log(result1); let x2 = [{ a: 1 }, { b: 2 }, 6] let y2 = [{ a: 1 }, 7, 6] let result2 = _.differenceWith(x2, y2, _.isEqual); console.log(result2); Output:Note: This will not work in normal JavaScript because it requires the library lodash to be installed. Comment More infoAdvertise with us Next Article Lodash _.drop() Method I iamsahil1910 Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Lodash Lodash Array Similar Reads Lodash _.chunk() Method Lodash _.chunk() function is used to break the array into small chunks. Each chunk is an array of sizes as given.Syntax:_.chunk(array, size);Parameters:array: An array to be processed by chunk function.size: This describes the size of the chunk.Return Value: It returns the array of chunks that is al 3 min read Lodash _.compact() Function Lodash _.compact() function is used to create an array with all false values removed in JavaScript. so it returns a new array of filtered values.Syntax:_.compact(array);Parameters:array: It is an array to be compacted.Note: The values are false, null, 0, "", undefined, and NaN are falsey.Return Valu 2 min read Lodash _.concat() Function Lodash _.concat() function is used to concatenate the arrays in JavaScript. and it returns the new concatenated array.Syntax:_.concat(array, [values]);Parameters:array: It is an array to which values are to be added.values: It is the Array of values that is to be added to the original array.Note: Th 3 min read Lodash _.difference() Function Lodash _.difference() function is used to remove a single element or the array of elements from the original array. This function works pretty much the same as the core function of JavaScript i.e. filter.Syntax:_.difference(array, [values]);Parameters:array: It is the array from which different elem 2 min read Lodash _.differenceBy() Method The Lodash _.differenceBy() method is used to remove the values from the original array by iterating over each element in the array by using the Iterate function. It is almost the same as _.difference() function.Syntaxlodash.differenceBy(array, [values], [iterate=_.identity])ParametersThis function 3 min read Lodash _.differenceWith() Method Lodash _.differenceWith() method is similar to the _.difference() method that returns the array containing the values that are in the first array not in the second array but in _.differenceWith() all the elements of the first array are compared with the second array by applying comparison provided i 3 min read Lodash _.drop() Method Lodash _.drop() method is used to drop the elements in a given array.Syntax:_.drop(array, number);Parameters:Array: It is the original array from which the elements are to be removed.Number: It is the number of elements to be removed from the array.Note: The elements are removed from the index 0 of 2 min read Lodash _.dropRight() Function Lodash _.dropRight() function is used to delete the elements from the right of the array i.e from the (n-1)th element.Syntax:Â _.dropRight(array, n);Parameters:array: It is the original array from which elements are to be deleted.n: Here n is the number of elements that are to be deleted from the arr 3 min read Lodash _.dropRightWhile() Function Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc. The _.dropRightWhile() function is used to delete the slice of the array excluding elements dropped from the end until the predicate function returns false.Synt 2 min read Lodash _.dropWhile() Method Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc. The Loadsh.dropWhile() method is used to return the slice of the given array. This takes a predicate function that iterates through each element of the array an 2 min read Like