I'm trying the following code but It's behaving weird.
Code:
const a = [{ x: 'c', y: 'z' }, { x: 'd' }];
const b = a[0];
b.x = 'dx';
a.splice(1, 0, b)
console.log(a)
Output:
[{x: "dx", y: "z"},{x: "dx", y: "z"}, {x: "d"}]
But I want:
[{x: "c", y: "z"},{x: "dx", y: "z"}, {x: "d"}]
Please help me!