网站介绍:在真实的场景中,究竟在哪些地方能体现闭包的存在?1.返回一个函数;function f1() { var a=2; return function f2() { console.log(a); //2 };};var num=f1();num();2.作为函数参数传递;var a = 1;function f1() { var a = 2; function f2() { console.log(a); }; f3(f2.._闭包体现
- 链接地址:https://aiguangyuan.blog.csdn.net/article/details/121384591
- 链接标题:JavaScript闭包有哪些表现形式?_闭包体现-CSDN博客
- 所属网站:aiguangyuan.blog.csdn.net
- 被收藏次数:8127
- 网站标签:闭包体现