Im writing some code atm with ES6 and Babel (es2015 preset) and I cant spread one Object as I am used to. Normally I would take an Object, use a spread and map the inner content like [...someObject].map(dosomestuff)
. But my one object does not behave as expected and the only difference I found so far are the keys:
let myObject = {
'key': content,
'key2': content,
'key3': content
};
let array = [...myObject];
Since the object gets generated form a file structure, the keys are formed by variables and can include special chars, so i need to set them like object[key] = value
. Why cant I use the spread operator on that object (the array is always empty)? And is there a workaround thats as comfortable as the spread-operator (I dont mean making a new Array with Object.keys and use that)