An infinite loop occurs when a loop condition always evaluates to true
, causing the loop to run forever. Be cautious when creating infinite loops to avoid freezing your program.
Example:
while (true) {
console.log('This is an infinite loop');
}
Tags: intermediate, JavaScript, Loops
URL: https://www.tiktok.com/@jsmentoring/photo/7469423331989622048