in ES6 simply
const a1 = ["a", "b", "c", "t"];
const a2 = ["d", "a", "t", "e", "g"];
console.log( a2.filter(x => !a1.includes(x)) );
(another option is a2.filter(x => a1.indexOf(x)===-1)
)
More Related Contents:
- Sorting array of object based on range of Numbers of String [closed]
- How do I check if an array includes a value in JavaScript?
- How to find the sum of an array of numbers
- JQuery .each() backwards
- Why does typeof array with objects return “object” and not “array”? [duplicate]
- How might I find the largest number contained in a JavaScript array?
- How to add an object to an array
- Check if an array is empty or exists
- Find and remove objects in an array based on a key value in JavaScript
- How to count the number of occurrences of each item in an array? [duplicate]
- Using jQuery to compare two arrays of Javascript objects
- Javascript – Generating all combinations of elements in a single array (in pairs)
- Get unique results from JSON array using jQuery
- Compare 2 arrays which returns difference
- What is the most efficient way to sort an Html Select’s Options by value, while preserving the currently selected item?
- Filter strings in Array based on content (filter search value)
- What does $(selector)[0] mean in jQuery?
- Sieve of Eratosthenes algorithm in JavaScript running endless for large number
- Remove occurrences of duplicate words in a string
- Can I append an array to ‘formdata’ in javascript?
- Create array of all integers between two numbers, inclusive, in Javascript/jQuery
- Convert js Array() to JSon object for use with JQuery .ajax
- Paint algorithm leaving white pixels at the edges when I color [duplicate]
- Finding all permutations of array elements as concatenated strings
- Sorting an Array of JavaScript Objects a Specific Order (using existing function)
- Creating an array consisting of the largest values of each sub-array does not work as expected
- Randomizing elements in an array?
- How to flatten array in jQuery?
- javaScript: Can a comma occur after the last set of values in an array?
- How to put all elements’ content in array using jQuery ?