Not the answer you're looking for? Browse other questions tagged, Where developers & technologists share private knowledge with coworkers, Reach developers & technologists worldwide, This is not what i am asking i just need index of that element in array b if its in both array a and b. email is in use. Removing duplicate strings using javascript, inArray, indexOf in a 2-dimensional array, Compare Two arrays for equality if they have nested objects in Jquery. Site design / logo 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. maybe class added to the element or removed from it after the first assignment. If so, how close was it? You can make objectsEqual() recursive, but then you need to be careful about infinite recursion. Making statements based on opinion; back them up with references or personal experience. If you preorder a special airline meal (e.g. Please tell us why you want to mark the subject as inappropriate. How to select all child elements recursively using CSS? if (this How to check if an array includes an object in JavaScript ? jQuery - how to check if two elements are the same? All browser compatibility updates at a glance, Frequently asked questions about MDN Plus. How can I explain to my manager that a project he wishes to undertake cannot be performed by the team? You could compare DOM elements. Remember that jQuery selectors return arrays which will never be equal in the sense of reference equality. Assuming Your checking two object i think thats the issue What you want to compare and what control(div, textbox, hiddenfield etc.,) is that? The objects may not (and most likely will not) be in the same order in each array. We can see from the sameness comparisons table below that this is due to the way that Object.is handles NaN. Chances are they have and don't get it. i know how to do it now thanks for your help but if i start iterating over millions record it will take a lot of time thanks for you help :) but i don't want to iterate over a million records, How Intuit democratizes AI development across teams through reusability. You could compare DOM elements. Each array shouldn't have any more than 10 objects. Relying on Object.is when the signedness of zeros is not taken into account can be hazardous. To learn more, see our tips on writing great answers. How do you ensure that a red herring doesn't violate Chekhov's gun? vegan) just to try it, does this inconvenience the caterers and staff? In my case I had strings which I knew to be arrays: But I cared if it was a complete match or only a partial match, so I used something like the following, based off of Sudhakar R's answer: If duplicates matter such that [1, 1, 2] should not be equal to [2, 1] but should equal [1, 2, 1], here is a reference counting solution: Thanks for contributing an answer to Stack Overflow! Does ZnSO4 + H2 at high pressure reverses to Zn + H2SO4? Why do many companies reject expired SSL certificates as bugs in bug bounties? How to Compare two Arrays are Equal using Javascript? When I do the following comparison I get false although both val() and value visually display the same value:12. Assuming: