gpt4 book ai didi

javascript - 如何理解 Javascript 中的闭包?

转载 作者:可可西里 更新时间:2023-11-01 01:33:28 25 4
gpt4 key购买 nike

<分区>

如何理解 Javascript 中的闭包?

In general terms, a closure is a function bound to one or more external variables. When it is called, the function is able to access these variables. In JavaScript, closures are often implemented when functions are declared inside another function. The inner function accesses variables of the parent one, even after the parent function has terminated

在这个声明中,“闭包是一个绑定(bind)到一个或多个外部变量的函数”,这是否意味着我们可以这样做:var myFun = Function(msg){...};正确吗?

“即使在父函数终止之后”是什么意思?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com