AI-powered
podcast player
Listen to all your favourite podcasts with AI-powered features
JavaScript - How to Serialize Closures
The on-click listener has to get moved out. The thing that quick-likes you do is to serialize closures. It serializes on a server a closure that has a particular state with whatever the counter happens to be and also a reference to another function which is the set count equivalent. So when I hand you back a function, that function acts as if it had lexically scoped, captured everything in the system. That's just JavaScript. We can really load that, right?