Say I have some context where variables are set and a λ-function is called which uses them directly:
function outerContext(){
...
var data = ...; // some data the script uses
...
someObject.method = function(){
data; // the variable is used here
};
...
}
I know that the dynamically created function has a snapshot of the context it was created in, so data
variable is accessible there.
What are the dangers I may face with such an approach when I use this dynamically created method? Should I always give this data
as an argument or is it ok?