I am saving an object, but later when I add new values it return undefined. I am attempting to set any value that is undefined to the initial value, but unsuccessfully. I have tried assigning it to a fixed value, but it also does not work, and I do not know the cause of the problem.
let initalObject = {
keyOne: true,
keyTwo: "string",
keyThree: 0,
}
let object = {
keyOne: true,
keyTwo: "string",
}
for (i = 0; i != Object.keys(initalObject).length; i++) {
if (Object.values(object)[i] == undefined) {
Object.values(object)[i] = Object.values(initalObject)[i];
}
}
Thank you!