Inheritance and scope
JavaScript
const doThing = function (thingName) {
const defaults = {
name: 'TBD',
// I would expect this to have a scope of window
move_1: function () {
console.log('Ima move, I run in the context of: ', this);
},
// I would expect this to have a scope of this object
move_2: () => {
console.log('Ima move TOO, but I run in the context of: ', this);
}
};
return Object.assign({}, defaults, { addedAfter: () => { console.log('addedAfter'); }});
};
const moo = doThing('JerryOnly');
moo.move_1();
moo.move_2();
moo.addedAfter();