javascript get elements in both 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:
- document getelementsbyclassname not getting all elements
- react native vector icons
- comment obtenir l'élément parent javascript
- page is loading from previous page scroll in reactjs
- javascript get list of class names
- vue store access state in actions
- how to check element has event or not in jquery
- json_encode escape \
- routes react
- mixin in styled components
- destructuring arrays with rest operator
- swap variables using temp javascript
- typeof javascript
- view background image in react native
- Function to convert an Array to an Associative array
- javascript add class
- jquery script url
- navigation react pass props
- loopback not null
- get serialize data javascript
- javascript muuttujan määrittely
- mutable array methods in javascript
- .fetch method
- add class to radium