Shallow copy is nothing but when trying to copy and change the contents of copied array {array containing objects and not primitive data types} the contents of the original array also got changed.
In the following case, why the dst[0]= {name : "tom"} is a deep copy and not a shallow copy (the contents of the original array "src" is not changed). On the contrary, the second operation which is dst[0].name= "tom" is creating a shallow copy as expected and changing the contents of src. Can someone please clarify this?
let src = [{
name: 'brat'
}, {
age: 40
}]
let dst = [...src]
// dst[0]={name:"tom"}
dst[0].name = "tom";
console.log(`src ${JSON.stringify(src)}`)
console.log(`dst ${JSON.stringify(dst)}`)