May I ask a question about the scope?

clipboard.png
front-end beginners have been around this scope for a long time today.
this is my code, and the result is that the background of the li element in it turns black directly, as if onmouseover had been overwritten. I found the solution, which is to bind hoverLi and leaveLi in for with bind (lisi) and assign properties with this, but why is that okay, so it makes me more confused about the scope. I would like to ask the great god to give me a reminder and answer. Thank you very much

Mar.06,2021

dude!
hoverLi is a method followed by a pair of () , which means to execute the method!

// 
function hoverLi(item) {
  return function() {
    item...
  };
}
The scope of the item of

hoveLi () refers to the function hoveLi; the direction of this has changed;
you can use closures
((i) {}) (i)


has nothing to do with scope.
is called a function call with parentheses, which is executed directly, and bind returns some kind of copy of the function.
you can do this if you don't want to use bind,

onmouseout = (function (i) {
    // 
    return function () {
        // mouseoverfunction
        // leaveLi()
        // i
        // 
        leaveLi(list[i])
    }}
)(i)
// 
Menu