Is a For Loop always executed at least once?

前端 未结 4 1807
栀梦
栀梦 2021-02-20 01:32

According to my teacher, a for-loop always executes at least once, even if the condition is not met.

Example (like I know it from C++):

for (int i=6; i &         


        
4条回答
  •  孤街浪徒
    2021-02-20 02:10

    You could say a for-loop is always evaluated at least once.

    But if a for-loop's condition is not met, its block will never execute.

    Because you didn't ask about other loops, I won't address those.

提交回复
热议问题