Discuss / JavaScript / 为啥会变成死循环???这里头也没循环结构啊

为啥会变成死循环???这里头也没循环结构啊

Topic source

alienation

#1 Created at ... [Delete] [Delete and Lock User]

只是想修改一下第一个例子,结果为什么是

error

end

done

无限循环???

function printTime() {
    throw new Error();
}
    
function setTimeout(){
    try {
        setTimeout(printTime, 1000);
        console.log('done');
    } catch (e) {
        console.log('error');
    } finally {
        console.log('end')
    }
}
setTimeout()

syncAck

#2 Created at ... [Delete] [Delete and Lock User]

你把`setTimeout`方法重定义了,这是个递归调用呀

alienation

#3 Created at ... [Delete] [Delete and Lock User]

我傻了


  • 1

Reply