前言
最近開發(fā)的時候發(fā)現(xiàn)严衬,Chrome
開發(fā)者調(diào)試工具中多了Step
按鈕澄者,主要是為了步入進(jìn)函數(shù)內(nèi)調(diào)試代碼笆呆。那么之前我們已經(jīng)有了Step into next function call
,可以步入進(jìn)函數(shù)調(diào)試粱挡。為什么Chrome
還要新出step
呢赠幕?
image.png
Step into next function call與Step'的區(qū)別
image.png
Step into next function call:執(zhí)行異步函數(shù)后,異步函數(shù)后面的代碼無法斷點(diǎn)到询筏¢叛撸快捷鍵F11
。
Step:執(zhí)行異步函數(shù)后嫌套,異步函數(shù)后面的代碼可以斷點(diǎn)到逆屡。快捷鍵F9
踱讨。
實(shí)驗(yàn)
<html>
<script>
debugger
setTimeout(() => {
alert(‘B’);
}, 2000);
console.log(‘A’);
</script>
</html>
Step into next function call:執(zhí)行異步函數(shù)setTimeout
后魏蔗,異步函數(shù)后面的代碼console.log(‘A’)
無法斷點(diǎn)到。
Step:執(zhí)行異步函數(shù)setTimeout
后痹筛,異步函數(shù)后面的代碼console.log(‘A’)
可以被斷點(diǎn)到莺治。
實(shí)驗(yàn)在線案例為:https://codepen.io/huihui/pen/poZpggJ