Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Comparing and Filtering two arrays

var array1 = ['apples', 'grapes', 'oranges', 'banana'],
  array2 = ['potato', 'pears', 'grapes', 'berries', 'apples', 'oranges'];

var intersection = array1.filter(function(e) {
  return array2.indexOf(e) > -1;
});

console.log(intersection);
Comment

comparing two arrays with filter javascript

var fullWordList = ['1','2','3','4','5'];
var wordsToRemove = ['1','2','3'];

var filteredKeywords = fullWordList.filter(
  word=>!wordsToRemove.includes(word)
//or
//word=>wordsToRemove.indexOf(word)<0
);
Comment

PREVIOUS NEXT
Code Example
Javascript :: accept only video in input type file below size 
Javascript :: js remove last char of string 
Javascript :: logic operators in javascript 
Javascript :: array as json 
Javascript :: axios post request javascript 
Javascript :: completablefuture async example 
Javascript :: javascript speech recognition 
Javascript :: async foreach 
Javascript :: iife in javascript 
Javascript :: google jquery 3.5.1 
Javascript :: password regex 
Javascript :: array of arrays to one array js 
Javascript :: javascript delay some seconds 
Javascript :: setinterval in react 
Javascript :: how to clear input value in antdesign form on submit 
Javascript :: ssr full form in nextjs 
Javascript :: for in range javascript 
Javascript :: Date object for local time and date 
Javascript :: object check null or empty 
Javascript :: dynamic button click in javascript 
Javascript :: Get the url and parse or url.parse deprecated solved 
Javascript :: append textarea jquery with value 
Javascript :: github remote 
Javascript :: aes 256 file encryption node js 
Javascript :: javascript create an array 
Javascript :: how to make bootstrap navbar to change on scroll 
Javascript :: add and get tokens to securestore expo 
Javascript :: browser detection 
Javascript :: javascript remove object element 
Javascript :: how to validate from and to date using date.parse in javascript 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =