javascript get elements that exist in two arrays
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:
- global scope js
- node js write file
- What is strict mode in Java Script ?
- input radio trigger select jquery
- node express dynamic route and error handler
- how to use flatlist keyextractor
- find year javascript
- how to code print in javascript
- javascript date to string
- angular tilt
- big o theory
- encrypt script code
- js alert
- javascript close window
- graphql yoga access http headers
- nextjs "mssql" server
- simple return data jquery
- javascript random number
- back press subscriptions i is not a function react native
- turn number into array javascript
- javascript fastest loop
- refresh page on button click jquery
- default value of functin atribute
- axios post with header