Because #2
is the function that is assigned to isPrime
. And you pass 17
to isPrime
. On the other hand, you call .memoize
(#1
) without passing any arguments to it:
(function() { ... }).memoize()
// ^^ no arguments
I don't understand at which point the memoize() call passes the num argument to the closure in #2.
It doesn't. memoize
returns a new function and it's that function to which the argument is passed.