Message from JavaScript discussions

April 2019

— Source is the object to grab properties from, target is the object to put properties into


So my idea is good because like this I can use currentGame like I would use a global variable and when it has to be exported or imported it doesn't effect the content of other classes

— I need to study this


const a = { foo: 'bar' };
const b = { bar: 'baz' };
Object.assign(a, b);
// changes and returns a
// a is { foo: 'bar', bar: 'baz' }

Message permanent page

— And what happens if the objects have the same properties?

— Source overrides the original

— It also accepts multiple sources

— Object.assign(a, b, c)
Only a gets changed
c overrides b which overrides a

— That's the solution to all my problems

— That will not apply for me then

— I needed to have a predictable pattern inside the code of characters of the game

— So now I can call currentGame without fear that there wouldn't be such object