How does the following scheme simulate the finally function of promise?

Source address

found an interesting piece of code in it

Promise.prototype["finally"] = function(callback) {
    var constructor = this.constructor
    return this.then(
        function(value){
            return constructor.resolve(callback()).then(function(){
                return value;
            })
        },
        function(reason){
            return constructor.resolve(callback()).then(function(){
                return constructor.reject(reason)
            })
        }
    )
}

this code is how to simulate the function of finally, solve, thank you!

Mar.05,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e52a6a-59755.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e52a6a-59755.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?