1

CoffeeScript has a lot of useful shorthand regarding arrays and objects with comprehensions and destructuring. is there a quick shorthand for comparing entire objects or multiple properties thereof? i.e.

activity.date() is selected.date() and activity.month() is selected.month()

would be something a little like

activity[date(), month()] is selected[date(), month()]

I haven't seen anything like that in the docs but I figured I'd ask.

2 Answers 2

4

I'm not aware of any such functionality in CoffeeScript itself, but the Underscore.js library includes an isEqual function for this:

var moe   = {name : 'moe', luckyNumbers : [13, 27, 34]};
var clone = {name : 'moe', luckyNumbers : [13, 27, 34]};
moe == clone;
=> false
_.isEqual(moe, clone);
=> true
Sign up to request clarification or add additional context in comments.

Comments

1

I'm afraid there's nothing like that, even more for function calls. You can use underscore's isEqual to achieve that.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.