Assume, we have two arrays,
array1 = [1,2,3,6,3,5,2,5,2,4,3] array2 = [3,4,5] How can I find the value "3" which resides inside array2 and then compare the same from array1 Any help is appreciated.
Thanks.
Assume, we have two arrays,
array1 = [1,2,3,6,3,5,2,5,2,4,3] array2 = [3,4,5] How can I find the value "3" which resides inside array2 and then compare the same from array1 Any help is appreciated.
Thanks.
Similar question here: How to remove specifc value from array using jQuery
From the linked page (replacing their values with yours):
var array1 =[1,2,3,6,3,5,2,5,2,4,3]; var array2 =[1,2,3] var removeItem = array2[jQuery.inArray(3,array2)]; //jQuery.inArray returns the index where the value (3) first appears in the array (array2) array1 = jQuery.grep(array1, function(value) { return value != removeItem; }); console.log(array1); //[1,2,6,5,2,5,2,4] Try
var arrayA = [1,2,3,6,3,5,2,5,2,4,3]; var arrayB = [3,4,5]; var arrayC = []; $('.arrayA').text('ArrayA: ' + arrayA); $('.arrayB').text('ArrayB: ' + arrayB); $.each(arrayA, function(indexA,valueA) { $.each(arrayB, function(indexB, valueB){ if(valueA == valueB) { alert(valueA); alert(valueB); return false; } }); });