Rewrite nested function declarations

Viewed 37

I would like to rewrite the nested function bar() from a point where the nested function is not in scope. Is that possible without rewriting the containing function foo()?

function foo() {
    console.log("1")

    function bar() {
        console.log("2")
    }
}

// Rewrite bar() from here somehow?
foo.bar = function() {
    console.log("3")
}
0 Answers
Related