I feel like my problem is really easy to solve, but I cannot see it. I have simple thing to do, get myObject
from another function and store this in my storage object. For this task I created storageHandler
function. Everything works fine, but Object.assign
is not reaching my 'ID'
that I declared in this function earlier. This is weird because I don't know how to tell my function that 'ID'
is variable, not a string. I just expect it to be {1212313: {...}}
but instead it gives me {ID: {...}}
.
Someone have any idea how to fix it?
let storage = {}
const myObject = {
ID: '1223424525221',
name: 'Thomas',
mail: 'example@example.com'
}
storageHandler = data => {
const {ID} = data;
Object.assign(storage, {ID: data})
console.log(storage)
}
storageHandler(myObject)