Ask the boss to help solve the problem of js, which is passed by the parameter.

var pow2 = make_pow (2); indicates that parameter n is passed in, but why is it that parameter n is not assigned when pow2 is printed?

Mar.12,2021

var pow2=make_pow(2);//pow2function
//:
pow2();

my understanding: console.log is a string of printed references, and the pow2, parameter is not running and is a formal parameter at this time. And the assignment you want is what happens at run time.


prints out a function that prints whatever it is, and does not automatically assign values according to the context of context . A simple and intuitive example:


make_powJS:

var pow2=make_pow(2);
console,log(pow2(3)); // 9

as to why pow2 can save the value of n, it involves the problem of closure.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35c7b-2bfb2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35c7b-2bfb2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?