Javascript Memoization Explanation?

前端 未结 6 1334
花落未央
花落未央 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:33

    There is a self-calling function that returns the function with the identifier fib which is then assigned to the identifier fibonacci. This way you can create a private variable memo which is only accessible by the function. So var fibonacci in fact is function(n){...}.

提交回复
热议问题