How is a closure different from a callback?

前端 未结 9 1071
伪装坚强ぢ
伪装坚强ぢ 2020-12-07 19:08

I asked a question about callbacks and arrived at another question (see comment). How is a closure different from a callback?

9条回答
  •  情话喂你
    2020-12-07 19:48

    Different definitions:

    Callback -

    a callback is executable code that is passed as an argument to other code.

    Closure -

    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.

提交回复
热议问题