Home > Article > Web Front-end > Detailed explanation of classic js closure
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);
Question: What is each output?
Answer:
undefined,0,0,0undefined,0,1,2undefined,0,1,1
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!