Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

diff two arrays javascript

function diffArray(arr1, arr2) {
  return arr1
    .concat(arr2)
    .filter(item => !arr1.includes(item) || !arr2.includes(item));
}
Comment

compare two array in javascript

let arr1 = [1, 4, 7, 4, 2, 3];
let arr2 = [1, 2, 3, 4, 7, 18];

const is_same = arr1.length == arr2.length &&
  (arr1.every((currElem)=>{
    if(arr2.indexOf(currElem)> -1){
      return (currElem == arr2[arr2.indexOf(currElem)]);
    }return false
  })
)
console.log(is_same)
Comment

how to compare two arrays javascript

function arraysAreIdentical(arr1, arr2){
    if (arr1.length !== arr2.length) return false;
    for (var i = 0, len = arr1.length; i < len; i++){
        if (arr1[i] !== arr2[i]){
            return false;
        }
    }
    return true; 
}
Comment

compare between two arrays javascript

const equals = (a, b) => JSON.stringify(a) === JSON.stringify(b);
let arr1 = ['1','2'];
let arr2 = ['1','2'];
equals(arr1,arr2)//this return false , if not equal then its return false
Comment

PREVIOUS NEXT
Code Example
Javascript :: addclass to elementref angular 
Javascript :: hot reload problem react 17 
Javascript :: remove validators angular 
Javascript :: eslint-disable-next-line 
Javascript :: owl carousel get started 
Javascript :: javascript title string 
Javascript :: js get random hex color 
Javascript :: clear file upload jquery 
Javascript :: how to get the integer part of a string in javascript 
Javascript :: how to set background colour i js inline stylel 
Javascript :: how to call web api with the useeffect hook in react 
Javascript :: React Hook "React.useState" is called in function "placeItem" which is neither a React function component or a custom React Hook function react-hooks/rules-of-hooks 
Javascript :: creating a class in angular 
Javascript :: getting state in react-router-dom v6 
Javascript :: react native copy to clipboard 
Javascript :: alphabet string javascript 
Javascript :: javascript test for empty object 
Javascript :: discord js check if person banned 
Javascript :: check if document is ready js 
Javascript :: js conditional key 
Javascript :: create file if not exists nodejs 
Javascript :: js setinterval 
Javascript :: antd modal hide ok button 
Javascript :: Bots latency discord js 
Javascript :: javascript format float 
Javascript :: regex repeat n times 
Javascript :: javascript to remove last character in string 
Javascript :: discord.js send message to a given channel 
Javascript :: js object get type 
Javascript :: concantene number in js 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =