Control Statement in Javascript
In this article, we will see about the control statement in javascript. The control statements help us to get control over the flow of execution of a code.
If you want to get control over the flow of execution of code, we take the help of the Javascript control statement. Javascript provides control transfer statements. The control transfer statement is a jumping statement used to skip a single or set of statements. We can solve any real-world problem by writing a program containing four programming language statements: sequential, conditional, control transfer, and iterative statements.
Sequential statements:
Its don’t break the normal flow of execution of code
Ex: variable declarations, assignment statements, etc.
var a;
a=10;
3 types of control statements
1. conditional/selection statement:
It executes code based on the result of a condition
- if,
- if else,
- else if ladder,
- switch case
2. Jumping/ control transfer statement:
It make the control to jump/transfer directly from one place ot another:
- break,
- continue,
- function call
- return
3. Looping/iterative statement:
It executes a set of statements repeatedly, which means if you want to execute a single or set of statements repeatedly take the help of a looping statement.
- for
- while
- do while
- for in.