Read more

Javascript: Comparing two arrays for equality

Henning Koch
March 06, 2013Software engineer at makandra GmbH

Don't Google this, you will lose all will to live. Instead use Object#isEqual() from Lodash Show archive.org snapshot or Underscore.js Show archive.org snapshot :

_.isEqual([1, 2], [2, 3]) // => false
_.isEqual([1, 2], [1, 2]) // => true
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

If your project already uses Unpoly Show archive.org snapshot you may also use up.util.isEqual() in the same way:

up.util.isEqual([1, 2], [2, 3]) // => false
up.util.isEqual([1, 2], [1, 2]) // => true

To compare two arrays for equality in a Jasmine spec assertion, see Jasmine: Testing complex types for equality.

Posted by Henning Koch to makandra dev (2013-03-06 19:36)