gpt4 book ai didi

JavaScript - 如何了解 "closures"的用法?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:53:13 25 4
gpt4 key购买 nike

来自维基百科,免费的百科全书:闭包(计算机科学)

In computer science, a closure is a function that is evaluated in an environment containing one or more bound variables. When called, the function can access these variables. The explicit use of closures is associated with functional programming and with languages such as ML and Lisp. Constructs such as objects in other languages can also be modeled with closures.

要在 JavaScript 中使用它,有人可以给我举一个例子来说明它是如何应用的吗?

最佳答案

搜索“javascript closures”可以找到很多令人鼓舞的链接。前三名是这两个(第三个链接是第二个的重新格式化版本):

如果这些对您没有帮助,请解释原因,以便我们能够更好地实际提供帮助。如果您在提问之前没有进行搜索,那么 - 下次请这样做:)

关于JavaScript - 如何了解 "closures"的用法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/212401/

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