Doubts about the nesting of setTimeout Multi-layer callback functions

I am a novice. I encountered some doubts when learning the asynchronism of javascript , as follows:
there is an example code like this in teacher Ruan Yifeng"s tutorial:

   

does not particularly understand the operation mechanism of the whole multi-layer callback. It seems that the parameters passed in will be "remembered" every time setTimeout is executed, but how to understand this code always feels special.

I hope there are seniors who can help with the answer. Thank you


is a callback process

var async = function(arg, callback) {
    console.log(`${arg}, `)
    setTimeout(function() {
        callback(arg * 2)
    }, 1000)
}

async(1, function(value){  //1value2
    async(value, function(value){ // vaule = 2 value4
        async(value, function(value){ // vaule = 4 value8 8
            console.log(': ', value)
        })
    })
})
Menu