mihaifm / linq

linq.js - LINQ for JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Contains Method does not Delivers True

StSchnell opened this issue · comments

Thank you very much for this great library.

These days I tried a few methods, including the Contains method. Here my code, which delivers false:

var numbers = Enumerable.from([
  {number: 10},
  {number: 9},
  {number: 8},
  {number: 7},
  {number: 6}
]);

console.log(JSON.stringify(numbers.contains({number: 9}))); // => false

I expected true here. Is my approach wrong here?

Thanks for hints and tips.

commented

JavaScript does shallow comparison, only primitive types can be compared directly 9 === 9 // true. You create two object instances which are always different: {number: 9} === {number: 9} // false.

Thank you very much @M0ns1gn0r for this clarification.