Javascript Memoization Explanation?

前端 未结 6 1322
花落未央
花落未央 2020-12-11 02:51

Reading an example from a book, can someone explain how the function call to fibonacci takes in the argument \'i\' when the function itself doesn\'t declare any parameters?<

6条回答
  •  情歌与酒
    2020-12-11 03:50

    var fibonacci = (function() {
        ...
        return fib;
    })();
    

    This is a self-executing function.

    It declares a function expression which returns a function (fib), executes the outer function expression immediately (()), and assigns its return value (which is fib) to the fibonacci variable.

提交回复
热议问题