Just wondering about overriding the closure functions behavior.
e.g. How can i override the baz() function in below snippet?
(function() {
var foo = 'Hello';
var bar = 'World!'
function baz(){
return foo + ' ' + bar;
}
})();
If you are outside the closure, you cannot override the baz() function that is inside the closure. Closures provide privacy and that works for local functions like it works for local variables.
If you are inside the closure, you can define a new version of baz() inside the closure or edit the code inside of baz().
Related question: Can I "extend" a closure-defined "class" in Javascript?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With