02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Break

What if you had enough of that loop , enough is enough lets break out of it.

Video Transcript

00:00I just put on to the stage a very simple for loop that we've played around many times before just to illustrate one new
00:07Concept which is called break. What is break?
00:10We've seen break before and if you recall what we were working with cases
00:15We broke out of a case whenever we wanted to get out of that key that switch
00:21And the same is true for for loops if I would start my for loop and immediately after my trace
00:27I would put a break command. That's all I had to do. It would force the loop to end
00:35Thus if I run my application even though it's in theory my eye is supposed to loop from 0 through 10
00:41It won't it's gonna hit that break and it's gonna leave
00:45Now obviously this doesn't really make sense to have a break immediately, but maybe in some scenario
00:50It's some random scenario. Let's say if I equals 3
00:56Then we would want to break out early and by doing that. We'll see that when I equals 3
01:04It will break out of that loop and that loop will not continue any further
01:12And that's all what we really need to know about break we've seen break before so it's not a new concept
01:18And we're integrating that to the known concept from before

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!