SBB SBB - 3 months ago 13
jQuery Question

jQuery compare two serialized objects

I am using a plugin that has an API for events

. When I start dragging the element in the grid, It creates a serialized array of all the data in its current state.

When the item is dropped, it also creates a serialized array of data.

I want to compare these two sets of data to see if it has changed at all. I don't want to trigger a database call to update the grid placement if the user started dragging something and then put it back in its previous spot.

I have tried comparing them as is using
and I have also used
on them first before comparing but have read that it could provide mixed results.

Is there an easy to way to compare two objects like this?

enter image description here


== checks if object's references are equal (doesn't compares content).

For deep object comparison, you can use lodash's isEqual().