javascript get intersection of two arrays
let intersection = arrA.filter(x => arrB.includes(x));function getArraysIntersection(a1,a2){
return a1.filter(function(n) { return a2.indexOf(n) !== -1;});
}
var colors1 = ["red","blue","green"];
var colors2 = ["red","yellow","blue"];
var intersectingColors=getArraysIntersection(colors1, colors2); //["red", "blue"]
Also in JavaScript:
- Firebase: Firebase App named '[DEFAULT]' already exists
- length of list in javascript
- iterate object js
- caesar cipher
- auto refresh page javascript
- convert json to arraylist java
- how to go back one directory in git bash
- create range array javascript
- prevent default on enter press
- user agents regex for mobile
- nodejs map
- how to do basic authentication with fetch api
- showing difference between dates in minutes js
- javascript regex single line
- javascript reduce
- javascript method to see if item exists in array
- javascript convert binary to text
- JSX not allowed in files with extension '.js'
- face-api without projects
- get first element of array javascript
- javascript foreach in object
- jquery ajax json
- javascript popup function
- js create object url base64 pdf binary