I have the following example. Both of the find() function works, but I am not sure how the first one with {} is passed into the callback function.
1.If {} is used, I assume an object is passed into the find function, but how does 'title' as an object can be used to compare with values(1.2). Can someone please explain the basics, with reference will be even better.
2.I understand the second find function is passing in object, and arr.title refers to the value inside the object 'array1'. I am right?
const array1 = [{name:1,title:1.1}, {name:2,title:1.2}];
const found = array1.find(({title}) => title ==1.2);
const found2 = array1.find(arr => arr.title ==1.2);
console.log(found);
console.log(found2);
The result of the code above is:
> Object { name: 2, title: 1.2 }
> Object { name: 2, title: 1.2 }