Flow-control structures: Difference between revisions

Content added Content deleted
(Added Haskell.)
(add JavaScript)
Line 1: Line 1:
[[Category:Less Than 20 Examples]]{{Task|Control Structures}}
{{Task|Control Structures}}
{{Control Structures}}
{{Control Structures}}
In this task, we document common flow-control structures. One common example of a flow-control structure is the <tt>goto</tt> construct. Note that [[Conditional Structures]] and [[Iteration|Loop Structures]] have their own articles/categories.
In this task, we document common flow-control structures. One common example of a flow-control structure is the <tt>goto</tt> construct. Note that [[Conditional Structures]] and [[Iteration|Loop Structures]] have their own articles/categories.
Line 401: Line 401:
=={{header|Java}}==
=={{header|Java}}==
"goto" is a reserved keyword in Java; but you cannot use it. There are currently no goto statements.
"goto" is a reserved keyword in Java; but you cannot use it. There are currently no goto statements.

=={{header|JavaScript}}==
* <code>'''return'''</code> from a function ([http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Statements/return])
* loop control with <code>'''break''' [label]</code> ([http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Statements/break]) and <code>'''continue''' [label]</code> ([http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Statements/continue])
* exceptions with <code>'''throw'''</code> ([http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Statements/throw]) and <code>'''try ... catch ... finally ...'''</code> ([http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Statements/try...catch])


=={{header|Perl}}==
=={{header|Perl}}==