I would do as follows;
var arr1 = [1,2,3,4],
arr2 = [2,4],
res = arr1.filter(item => !arr2.includes(item));
console.log(res);
More Related Contents:
- Filter JSON by key value with JavaScript
- Filter array of objects based on another array in javascript
- javascript filter array multiple conditions
- How to map more than one property from an array of objects
- Filter array of objects with another array of objects
- How to filter an array in javascript?
- How can I only keep items of an array that match a certain condition?
- Javascript: filter array of objects by array of strings
- Filtering array of objects by searching nested object properties
- Recursively filter array of objects
- JavaScript filter array by data from another
- Removing undefined values from Array
- How to use Array.prototype.filter with async?
- Filter nested array in object array by array of values
- Map/Set to maintain unique array of arrays, Javascript
- filter array of objects by another array of objects
- Convert Array to Object
- How can I access and process nested objects, arrays or JSON?
- Obtain smallest value from array in Javascript?
- Checking for duplicate strings in JavaScript array
- Sort an array of objects by multiple properties
- A better way to splice an array into an array in javascript
- Sum values from an array of key-value pairs in JavaScript
- Issue with JSON.stringify adding a extra \ and “” to my Json object
- Create a dynamic nested object from array of properties
- How to access array in circular manner in JavaScript
- Javascript: Sort array of arrays by second element in each inner array
- Most efficient way to prepend a value to an array
- Vue JS returns [__ob__: Observer] data instead of my array of objects
- Getting max value(s) in JSON array