Skip to content
Advertisement

Tag: compare

Checking for duplicate strings in JavaScript array

I have JS array with strings, for example: I need to compare for duplicate strings inside array, and if duplicate string exists, there should be alert box pointing to that string. I was trying to compare it with for loop, but I don’t know how to write code so that array checks its own strings for duplicates, without already pre-determined

Generic deep diff between two objects

I have two objects: oldObj and newObj. The data in oldObj was used to populate a form and newObj is the result of the user changing data in this form and submitting it. Both objects are deep, ie. they have properties that are objects or arrays of objects etc – they can be n levels deep, thus the diff algorithm

How to know if two arrays have the same values

I have these two arrays: one is filled with information from an ajax request and another stores the buttons the user clicks on. I use this code (I filled with sample numbers): But it always gives false, even if the two arrays are the same, but with different name. (I checked this in Chrome’s JS Console). So, is there any

Compare two dates with JavaScript

Can someone suggest a way to compare the values of two dates greater than, less than, and not in the past using JavaScript? The values will be coming from text boxes. Answer The Date object will do what you want – construct one for each date, then compare them using the >, <, <= or >=. The ==, !=, ===,

Advertisement