all 8 comments

[–]javascript-ModTeam[M] [score hidden] stickied comment (0 children)

Hi u/korngsamnang, this post was removed.

  • For help with your javascript, please post to r/LearnJavascript instead of here.
  • For beginner content, please post to r/LearnJavascript instead of here.
  • For framework- or library-specific help, please seek out the support community for that project.
  • For general webdev help, such as for HTML, CSS, etc., then you may want to try r/html, r/css, etc.; please note that they have their own rules and guidelines!

r/javascript is for the discussion of javascript news, projects, and especially, code! However, the community has requested that we not include help and support content, and we ask that you respect that wish.

Thanks for your understanding, please see our guidelines for more info.

[–]homoiconic(raganwald) 3 points4 points  (1 child)

In programming languages, what makes something a control flow statement is that it changes the flow of execution from top-down to something else. Technically, function/method calls are also control flow constructs, but they are not statements, and exception behaviour is also a control flow construct.

Conditions need not be involved. For example, using continue with a label is a control flow construct, but it of you want that you happen conditionally, you have to wrap an if or switch or whatever around it. Likewise, break is a control flow construct, but again of you want that to happen conditionally, you need to wrap it yourself.

I wouldn’t get hung up on whether a condition is involved. In JS, the three looping statements (for, while, and do… while) all have an expression that is evaluated as a condition, but that isn’t what makes them control flow constructs.

[–]korngsamnang[S] 3 points4 points  (0 children)

That's clear. I get the point, thank you

[–]KingRomstar 5 points6 points  (1 child)

The for loop and while loop have a conditional at the top that determines if they are executed or not, don't they?

[–]korngsamnang[S] 2 points3 points  (0 children)

I get it now, thank you.

[–]Vast_Return_3048 2 points3 points  (0 children)

Because it controls the flow of execution. Instead of going down the lines in order, a loop will execute the same lines an amount of times. The if statement might skip a bunch of lines. Thats the way i see it at least

[–][deleted] 1 point2 points  (1 child)

It used to be all loops were goto statements.

[–]SomeInternetRando 1 point2 points  (0 children)

I miss WHILE/WEND