を、配列の配列を渡す:は、私はオブジェクトを含む配列の配列を持っているlodash交差点に
let data = [[{a:0}, {b:1}], [{a:1}, {b:1}]]
今、私は私が行うと[{b:1}]
を返し、これら2つの配列のlodash intersectionを作りたいと思いますこれは:
import {intersection} from 'lodash'
return intersection([{a:0}, {b:1}], [{a:1}, {b:1}])
結果は正しいです。
しかし、私は
return intersection(data)
を行うとき、私はちょうど同じ結果を取り戻します。
すべての配列をデータから交差関数に渡す簡単な方法はありますか?私の最初の考えは.mapを使用することでしたが、これは別の配列を返します...
私はあなたが値ではなく参照を比較していると信じているので、これから何かを得ることはできません。代わりに['intersectionBy'](https://lodash.com/docs/4.17.4#intersectionBy)または[' intersectionWith'](https://lodash.com/docs/4.17.4#intersectionWith)を使用する必要があります。 – mhodges