JavaScript - Declaring Global Scope for Nested Function?

前端 未结 5 1268
忘了有多久
忘了有多久 2021-02-14 00:36

My attempts at giving global scope to a nested JavaScript function are not working:

//DECLARE FUNCTION B IN GLOBAL SCOPE
function B;

function A() {

    //DEFIN         


        
5条回答
  •  一向
    一向 (楼主)
    2021-02-14 01:00

    What about:

    function A() {
        window.B = function() {
            alert("function B is running");
        }
    }
    //CALL FUNCTION B FROM GLOBAL SCOPE
    B();
    

提交回复
热议问题