samedi 17 septembre 2016

Detecting closures using reflection in JavaScript

Is it possible to get all variables captured by a closure in runtime?

For example, in .NET, closures are internally implemented by hoisting the captured variables to properties of a compiler-generated class, so it's easy to get them using MethodInfo.DeclaringType.GetFields.

How would you do this in JavaScript? I know the closures are available inside the engine, but are they exposed to JS?





Aucun commentaire:

Enregistrer un commentaire