Wait for the function to return the result

function abc () {

: 1  0

}

var aaa = abc ();
when executed in this way, aaa is undefined

ask the teacher how to get the correct return value. Thank you

May.06,2021

bind events in user actions


the context is so unclear that it is recommended that callbacks can be used:

function abc(callback){
    // result 
    callback(result)
}

function callback(result){
    console.log(result)
}

I guess the abc () function of the landlord is an asynchronous function. Then you want to return data in this asynchronous function, only to find that it is undefined .

Menu