I am doing “Use a Mixin to Add Common Behavior Between Unrelated Objects” Challenge.
So what we need to do is to create a function like this:
let flyMixin = function(obj) {
obj.fly = function() {
console.log("Flying, wooosh!");
}
};
And in the challenge, I create something like this.
function flyMixin(obj) {
obj.fly = function() {
console.log("Flying, wooosh!");
}
};
I think they are basically just the same. The only difference is the first one declare a function in a variable, the latter using directly function declaration.
I can’t understand the purpose of making it exactly like the first one. Is there any necessity of doing so that I missed?
Thank you.