Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript compare values of two arrays

const a = ['Left', 'Right'];
const b = ['Right', 'Left'];

//	true if a and b contain the same values
//	false otherwise
const c = a.sort().join(',') === b.sort().join(',');
Comment

js compare elements of two arrays

var array1 = ["cat", "sum","fun", "run", "hut"];
var array2 = ["bat", "cat","dog","sun", "hut", "gut"];

console.log(array1.diff(array2));
Comment

comparing two arrays in javascript

const arr1 = [1, 2, 3];
const arr2 = [1, 3, 3];

if (arr1.length !== arr2.length) return console.log("false");
for (let i = 0; i < arr1.length; i++) {
    for (let j = 0; j < arr2.length; j++) {
        if (arr1[i] === arr2[j]) {
            console.log("yes match", arr1[i], arr2[j]);
            continue;
        }
        console.log("no match", arr1[i], arr2[j]);
    }
}
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 :: js how to check is array empty es6 
Javascript :: how to use uniqid 
Javascript :: toarray javascript 
Javascript :: copy link to clipboard 
Javascript :: javascript get specific timezone 
Javascript :: how to get common elements from two array in javascript using lodash 
Javascript :: loop through an array in js 
Javascript :: alpinejs with select 
Javascript :: reactsj substring 
Javascript :: get element of an array inside another array 
Javascript :: span change jquery 
Javascript :: how to start a node server 
Javascript :: nuxt query params 
Javascript :: format html in jsx vscode 
Javascript :: jquery equivalent of document.getelementbyid 
Javascript :: mongoose multiple populate 
Javascript :: preg_match javascript 
Javascript :: add property to all documents mongo 
Javascript :: number to array js 
Javascript :: mongodb data types 
Javascript :: angular capitalize first letter 
Javascript :: Use Multiple Conditional Ternary Operators Javascript 
Javascript :: javascript object without undefined values 
Javascript :: how to get an array from another script in js 
Javascript :: return all elements of javascript array except the first item 
Javascript :: how to get a user input in js 
Javascript :: cart page url in shopify 
Javascript :: how to display array values in javascript 
Javascript :: search datatable vuetify 
Javascript :: discord.js start code 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =