Skip to main content
expanded on the jquery 3.x.x usage concern
Source Link
Chris Porter
  • 3.7k
  • 28
  • 29

There is an easy way...

$(arr1).not(arr2).length === 0 && $(arr2).not(arr1).length === 0

If the above returns true, both the arrays are same even if the elements are in different order.

NOTE: This works only for jquery versions < 3.0.0 when using JSON objects

There is an easy way...

$(arr1).not(arr2).length === 0 && $(arr2).not(arr1).length === 0

If the above returns true, both the arrays are same even if the elements are in different order.

NOTE: This works only for jquery versions < 3.0.0

There is an easy way...

$(arr1).not(arr2).length === 0 && $(arr2).not(arr1).length === 0

If the above returns true, both the arrays are same even if the elements are in different order.

NOTE: This works only for jquery versions < 3.0.0 when using JSON objects

added 54 characters in body
Source Link
suDocker
  • 8.5k
  • 6
  • 28
  • 26

There is an easy way...

$(arr1).not(arr2).length === 0 && $(arr2).not(arr1).length === 0

If the above returns true, both the arrays are same even if the elements are in different order.

NOTE: This works only for jquery versions < 3.0.0

There is an easy way...

$(arr1).not(arr2).length === 0 && $(arr2).not(arr1).length === 0

If the above returns true, both the arrays are same even if the elements are in different order.

There is an easy way...

$(arr1).not(arr2).length === 0 && $(arr2).not(arr1).length === 0

If the above returns true, both the arrays are same even if the elements are in different order.

NOTE: This works only for jquery versions < 3.0.0

added 2 characters in body
Source Link
Ohad Schneider
  • 38.5k
  • 16
  • 178
  • 211

There is an easy way...

$(arr1).not(arr2).length ===== 0 && $(arr2).not(arr1).length ===== 0

If the above returns true, both the arrays are same even if the elements are in different order.

There is an easy way...

$(arr1).not(arr2).length == 0 && $(arr2).not(arr1).length == 0

If the above returns true, both the arrays are same even if the elements are in different order.

There is an easy way...

$(arr1).not(arr2).length === 0 && $(arr2).not(arr1).length === 0

If the above returns true, both the arrays are same even if the elements are in different order.

The jQuery object has a length property. No need to convert to an array with .get().
Source Link
Loading
Source Link
suDocker
  • 8.5k
  • 6
  • 28
  • 26
Loading