two "for" loops can be executed at the same time? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

two "for" loops can be executed at the same time?

15th Apr 2021, 5:03 PM
JoseD
JoseD - avatar
5 Answers
+ 4
JoseD No process will go on step by step. After running first for loop 2nd will start.
15th Apr 2021, 5:07 PM
A͢J
A͢J - avatar
+ 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.
15th Apr 2021, 5:09 PM
CamelBeatsSnake
CamelBeatsSnake - avatar
+ 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.
17th Apr 2021, 1:10 PM
Vamsi Chowdary
Vamsi Chowdary - avatar
+ 1
Can't we use Threading in javascript ??
17th Apr 2021, 11:22 AM
🌀 Shail Murtaza شعیل مرتضیٰ
🌀 Shail Murtaza شعیل مرتضیٰ - avatar
+ 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.
17th Apr 2021, 11:55 AM
CamelBeatsSnake
CamelBeatsSnake - avatar