Skip to content

Instantly share code, notes, and snippets.

@pgainda
Created May 18, 2013 14:14
Show Gist options
  • Save pgainda/5604550 to your computer and use it in GitHub Desktop.
Save pgainda/5604550 to your computer and use it in GitHub Desktop.
Let's say we have a loop and there's some condition that makes us want to immediately stop the loop. There's a handy statement called break that lets us do just that. It works for both for and while loops, but not for recursion. It's similar to return (which lets you end a function), but is specifically for loops only.
while (true) {
console.log("I only print once!");
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment