Lodash: Problem with _.difference

Created on 4 Nov 2015  路  3Comments  路  Source: lodash/lodash

I want to the set difference arrayA - arrayB , but when the arrayA include array, it does not work.
e.g

console.log(_.difference([[1]],[[1]]));
// -> [[1]] ,not []

I see samevalueszero http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero
seems like Return true if x and y are the same Object value. Otherwise, return false.
We alwasy compare two arrays use Array.toString() and compare the string

var arrayA = [1], arrayB = [1];
arrayA.toString() === arrayB.toString() // true
arrayA == arrayB //false;

How can i get the difference in that times?

question

Most helpful comment

This is coming in v4 as _.differenceWith(array, other, _.isEqual).

All 3 comments

Do you actually want the difference or to compare two objects for equivalence?

This is coming in v4 as _.differenceWith(array, other, _.isEqual).

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jwngr picture jwngr  路  3Comments

dwoldrich picture dwoldrich  路  3Comments

sofianito picture sofianito  路  3Comments

andreineculau picture andreineculau  路  3Comments

thoraage picture thoraage  路  3Comments