const courses = [
{'id':101,'name':'Complete Web Dev'},
{'id':102,'name':'DS and Algo'},
{'id':103,'name':'React'}
];
let num = courses.find(c=>{
if(c.id===102)
return c;
});
num.name="Programming Fundamentals"
console.log(courses);
Can anyone please explain to me that when I am changing the value returned from the find function then why do the values inside the original array changes? Is there a concept that I am missing? After executing the code I am getting the below-mentioned output.
[
{ id: 101, name: 'Complete Web Dev' },
{ id: 102, name: 'Programming Fundamentals' },
{ id: 103, name: 'React' }
]