I have some nested functions such as
var freak = function() {
var die = function() { ... }
die(this);
}
As far as I have learned, the die function will get created (allocated) each time freak is called.
So if freak gets called a lot of time, that means a lot of memory will be wasted (assuming die is not using anything from freak's context; in other words, it works fine even if it was allocated only once and shared between multiple calls of freak – this is what I meant with wasted).
Is my understanding correct? And does that mean nested functions should be avoided entirely?