Home > Web Front-end > JS Tutorial > body text

Detailed explanation of classic js closure

零下一度
Release: 2017-07-20 17:12:06
Original
1545 people have browsed it

When I re-read js closure, I saw "Classic JS Closure Interview Questions Most People Do Wrong", and I understood and recorded my thoughts. Many bloggers have already explained it in detail, but the explanation behind it is a bit convoluted.

Post the code first

                fun:                   a = fun(0 a.fun(1 a.fun(2 a.fun(3   b=fun(0).fun(1).fun(2).fun(3  c= fun(0).fun(1 c.fun(2 c.fun(3);
Copy after login

Question: What is each output?

Answer:

undefined,0,0,0undefined,0,1,2undefined,0,1,1
Copy after login

Let’s break it down step by step:

The above is the detailed content of Detailed explanation of classic js closure. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!