When I put an object into array using push method and then change the value of the object, the value of the object in the array also changes. How to prevent it?
function onLoad() {
let array = []
let object = {}
object[1] = [1,2]
array.push(object)
object[1] = [1,3]
console.log(array)
}
onLoad();
I would like the code console [{1,2}] but it will console [{1,3}].
Would anyone know how to fix this?