+ 1
two "for" loops can be executed at the same time?
6 Answers
+ 4
JoseD
No process will go on step by step. After running first for loop 2nd will start.
+ 4
JoseD You can nest a for loop. Be mindful of nesting too much (too many levels of nesting). It can get complex very fast.
When you have a nested loop, the loops aren't executed at the same time, strictly speaking. One level nesting means the internal loop runs for every item in the outer loop.
+ 2
In programming languages, the code excute from step by step. We write code line by line for readability.
So, we can write two for loops in a code and it is called as nested for loop. But first for loop executes then goes to second for loop.
+ 1
Can't we use Threading in javascript ??
+ 1
🌀 Shail Murtaza شعیل مرتضیٰ No, it's single-threaded in terms of what the user can control, but it's non-blocking thanks to the event loop. In newer versions of node, you can use worker threads to solve some of the problems traditional threading might solve. You have the web worker API in the browser.