How to print function name in js

< H2 > the parameter in one function is another function, how to print the function name < / H2 > in this function?

for example:

funtion A() {
....
}
function B(A) {
    //A
    }

B ();

May.08,2022

directly A.name ah, as long as A is not an anonymous function.


function B (A) {console.log (A.name)}


in non-strict mode: arguments.caller
in strict mode: get the code of function A through A.toString () , and extract the function name

by regular.
Menu