/luːp/
noun — "the part of your code that gets stuck repeating itself… intentionally."
Loop is a programming construct that repeatedly executes a block of statements as long as a specified condition is true or until a termination criterion is met. Loops allow automation of repetitive tasks, iteration over data structures, and dynamic control flow in software applications.
Technically, Loop involves:
- Initialization — setting up variables or state before the loop starts.
- Condition checking — evaluating whether the loop should continue executing.
- Iteration — performing the loop’s statements and updating variables.
- Termination — exiting the loop when the condition is no longer satisfied.
Examples of Loop include:
- A
forloop iterating over an array of user IDs. - A
whileloop reading lines from a file until the end is reached. - A
do-whileloop that guarantees the block executes at least once before checking the condition.
Conceptually, Loop is your program’s way of saying “do this again and again until I tell you to stop.” Efficient looping is critical for performance, especially when handling large datasets or real-time operations.
In practice, Loops interact with statements, functions, and runtime environments. Proper loop control prevents infinite loops, ensures correct output, and maintains application responsiveness.
See Statement, Function, Runtime, Conditional, Debugging.