Every time you call the jQuery() function, a new object is created and returned. Same-value equality is provided by the Object.is method. How to get the child element of a parent using JavaScript ? Identify those arcade games from a 1983 Brazilian music video. email is in use. It's very nice, thanks. . Well, if you want to compare only the contents of arrays, there's a useful jQuery function $.inArray(). Is there a proper earth ground point in this switch box? Do new devs get fired if they can't solve a certain bug? Did this satellite streak past the Hubble Space Telescope so close that it was out of focus? Please don't post non-answers as "solution". How can I know which radio button is selected via jQuery? Connect and share knowledge within a single location that is structured and easy to search. This model falls short with Object.is, because it isn't "looser" than double equals or "stricter" than triple equals, nor does it fit somewhere in between (i.e., being both stricter than double equals, but looser than triple equals). Good solution, but I'm not sure this is accounting for the arrays having the same elements, but in a different order. Random AirCoded example of testing "set equality" in jQuery: $.fn.isEqual = function($otherSet) { You can use compare the individual members one by one though, there are no utilities for this that I know of in jQuery. What Does Setting the Length of a JavaScript Array Do. Now compare both JSON strings using the comparison operator (==) to check whether both What is the correct way to screw wall and ceiling drywalls? We can see from the sameness comparisons table below that this is due to the way that Object.is handles NaN. NOTE: This works only for jquery versions < 3.0.0 when using JSON objects, I was also looking for this today and found: Hide elements in HTML using display property. So even equality checks on the same selectors will fail. JSONP: //jsfiddle.net/echo/jsonp/ Roadmap (vote for features) How to react to a students panic attack in an oral exam? Approach 1: Use is() method to check both selected elements are same or not. Find centralized, trusted content and collaborate around the technologies you use most. Given an HTML document containing two elements and the task is to check whether both elements are same or not with the help of JavaScript. Please tell us why you want to mark the subject as inappropriate. How to follow the signal when reading the schematic? Why is this sentence from The Great Gatsby grammatical? 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! Your checking two object i think thats the issue What you want to compare and what control(div, textbox, hiddenfield etc.,) is that? The collection results you get back from a jQuery collection do not support set-based comparison. You can use compare the individual members one b In which case I think the code for it would be: My approach was quite different - I flattened out both collections using JSON.stringify and used a normal string compare to check for equality. The this in .each() as well as the second argument is the DOM element per iteration. Assuming: