underscore
underscore copied to clipboard
_.eq
Related to and really depending on #2453:
An _.eq
method to enable the SameValueZero comparison for composition.
Hello, @jdalton! Can you give an use case example for composition of this functions?
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, may I follow ECMA to implement SameValueZero functionality and why you doesn't like private method 'eq'?
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.