CodeNewbie Community

loading...

How does `break` work in JavaScript?

Gavin
・1 min read

Hola everyone! I've been doing the community taught JS-developer thing, but I've hit a snag recently. Or should I say a break?

I'm having a tough time figuring out how break works - can someone provide some clarity?

Discussion (1)

Collapse
ansellmax profile image
Ansell Maximilian • Edited

It just "breaks" you out of a loop iteration and switch statements. If your code come finds a break statement during a loop iteration, it will skip that iteration and go to the next (based on some condition, for example).