UPDATE: Despite being labeled as a duplicate, this question showcases @ssube's clever and efficient solution.
UPDATE2: A new method has been suggested by @Grungondola in the comments.
I'm currently working with Typescript.
This first code snippet works like a charm:
var array1 = [];
array1.push(5);
array1.push(6);
console.log("a", array2.indexOf(6));
However, the second snippet encounters an issue. The array2.indexOf returns -1, signifying that the item was not found:
var array2 = [];
array2.push({aa:5,bb:5});
array2.push({aa:6,bb:6});
console.log(array2.indexOf({aa:6,bb:6}));
It appears that indexOf does not support Objects. Are there alternative methods within TypeScript to tackle this problem? Thank you.