I am struggling with the fact that the flow of control in javascript is not what I'm used to. Not linear. Sometimes when I test I get the error message "A script is slowing down your browser" at times when everything should be stopped.
I spend ages looking for the bug. This time it was something really silly, a variable which stopped the function when it reached 350 px. Then I added a way to change the speed and sometimes this variable was incremented by 3 at each step. So it never reached 350, it went from 348 to 351.
So I was wondering if there was a "STOP!" mand. Something which would leave the display of the web page in its current state but stop all running processes?
I am struggling with the fact that the flow of control in javascript is not what I'm used to. Not linear. Sometimes when I test I get the error message "A script is slowing down your browser" at times when everything should be stopped.
I spend ages looking for the bug. This time it was something really silly, a variable which stopped the function when it reached 350 px. Then I added a way to change the speed and sometimes this variable was incremented by 3 at each step. So it never reached 350, it went from 348 to 351.
So I was wondering if there was a "STOP!" mand. Something which would leave the display of the web page in its current state but stop all running processes?
Share Improve this question asked Apr 1, 2021 at 15:58 Alain ReveAlain Reve 3211 gold badge2 silver badges15 bronze badges 2- 3 The answer is: No – epascarello Commented Apr 1, 2021 at 16:02
-
1
you should fix the logic, there is nothing prevent you from
return
– apple apple Commented Apr 1, 2021 at 16:15
2 Answers
Reset to default 7Debugger? It just creates a breakpoint, where you can analyse what's going on right now. I know it's not exactly what you're asking about, but it could work for your use case.
Usage
debugger;