You don't know JS, YET
Learning from book You don't know JS, YET Chapter 3
by moojjoo
HTML
<a href="https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/get-started/apA.md">https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/get-started/apA.md</a>
<p>
The fact that both the inherited and overridden methods can have the same name and co-exist is called polymorphism.
</p>
JavaScript
function classroom(teacher) {
return function study() {
console.log(
`${ teacher } says to study ${ this.topic }`
);
};
}
var assignment = classroom("Kyle");
var homework = {
topic: "JS",
assignment: assignment
};
homework.assignment();
// Kyle says to study JS
var otherHomework = {
topic: "Math"
};
assignment.call(otherHomework);
// Kyle says to study Math