indexOf() checks the reference of the object inside the array. Since you are making a new object and passing it as an argument to indexOf() it doesn't match the reference of object inside the array so it fails.
let arr = [{name: 'pippo',lastname: 'p'},{name: 'mickey',lastname: 'mouse'}]
arr.indexOf(arr[1])
Whereas this code will return 1 as expected as the reference is same.
Solution as given by @Ankit
arr = [{name: 'pippo',lastname: 'p'},{name: 'mickey',lastname: 'mouse'}]
x ={name: 'mickey', lastname: 'mouse'}
console.log(arr.findIndex((obj) => obj.name == x.name && obj.lastname === x.lastname));