const array1 = [1, 2, 3, 4]; const array2 = [2, 4]; const difference = _.difference(array1, array2); console.log(difference); // output: [1, 3]
const array1 = [1, 2, 3, 4]; const array2 = []; const difference = _.difference(array1, array2); console.log(difference); // output: [1, 2, 3, 4]In this example, `array2` is an empty array, which means that there is no element to remove from `array1`. As a result, the output of `_.difference` will be the original array1. The underscore `_difference` function belongs to the Underscore.js package library.