underscore icon indicating copy to clipboard operation
underscore copied to clipboard

_.eq

Open jdalton opened this issue 8 years ago • 4 comments

Related to and really depending on #2453: An _.eq method to enable the SameValueZero comparison for composition.

jdalton avatar Mar 01 '16 21:03 jdalton

Hello, @jdalton! Can you give an use case example for composition of this functions?

moredure avatar Mar 14 '16 17:03 moredure

Sure thing. See lodash/blob/npm/eq.js for an implementation reference.

This method extracts the SameValueZero comparison which would be what methods like _.indexOf, _.includes, _.difference, _.intersection, _.lastIndexOf, _.uniq, & _.union use for value comparisons.

It can be used as a shallow _.isEqual (without the recursive comparison bit).

jdalton avatar Mar 14 '16 17:03 jdalton

@jdalton, may I follow ECMA to implement SameValueZero functionality and why you doesn't like private method 'eq'?

moredure avatar Mar 14 '16 18:03 moredure

may I follow ECMA to implement SameValueZero functionality

You can though it's just the long way around of basically === + NaN. For reference here are the spec steps for ===.

why you doesn't like private method 'eq'

Private helpers and their names didn't factor into it.

jdalton avatar Mar 14 '16 19:03 jdalton