Creating function with variable

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.

The two forms are exactly equivalent. It’s just customary when using the block syntax to use a named function, whereas assigning it to a variable is more commonly used with arrow functions.

If you use this you can later declare a variable flyMixin and not being able anymore to use that function anymore, if you use let or const you don’t have this issue as you can’t redeclare variables declared with those