Search code examples
javascriptobjectcomparisoncoffeescriptequality

Test object equality in CoffeeScript?


Is there a simple way to test equality of objects in CoffeeScript?

Or more correctly - test if the properties of two objects are identical.

With these objects:

obj1 =
  name: "John Doe"
  age: "3.14"

obj2 =
  name: "John Doe"
  age: "3.14"

This evaluates false, as expected:

obj1 == obj2

For now I'm using Underscore's isEqual


Solution

  • Nope. CoffeeScript doesn't provide this as a language feature, so using a library like Underscore.js is your best option.