SOURCE

const supportPromise = typeof Promise === 'function'

const supportMutationObserver = typeof MutationObserver ==='function'

function addToMicroTasking(fn) {
    if (supportPromise) {
        return Promise.resolve(fn)
    }else if (supportMutationObserver) {
        const mutationObserver = new MutationObserver(fn)
        const text = document.createTextNode('0')
        mutationObserver.observe(text, {
            characterData: true
        })
        text.data = '1'
    } else{
    setTimeout(fn, 100)
    }
}
console 命令行工具 X clear

                    
>
console