我需要在a某处声明变量,并使用javascript技术使其在f2函数内部被调用时可见f1.但是直接调用(f1函数外部)f2函数必须无法打印.我不能使用eval.我无法改变f2功能.我可以随意改变f1功能.这有可能吗?
function f1(var_name){
f2();
}
function f2(){
console.log(a);
}
f1(); // must log value of the a
f2(); // must not be able to log a
Run Code Online (Sandbox Code Playgroud)