Skip to content

Instantly share code, notes, and snippets.

@og-shawn-crigger
Created October 4, 2012 18:42
Show Gist options
  • Save og-shawn-crigger/3835554 to your computer and use it in GitHub Desktop.
Save og-shawn-crigger/3835554 to your computer and use it in GitHub Desktop.
jQuery Array Compare
/**
* Compare two arrays if the are equal even if the have different order.
*
* @link http://stackoverflow.com/a/7726509
*/
jQuery.extend({
/**
* @param {array} a
* First array to compare.
* @param {array} b
* Second array to compare.
* @return {boolean}
* True if both arrays are equal, otherwise false.
*/
arrayCompare: function (a, b) {
return $(a).not(b).get().length === 0 && $(b).not(a).get().length === 0;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment