[X]

Javascript Break, Continue and With Statements - (Learning Javascript Series)

Javascript Break, Continue and With Statement

Break and continue statements are part of almost every programming language. They provides ability to stop/skip the execution in a program flow. These statements are only used inside a loop or switch statement. They are not valid outside of switch/loop statement.

Break statement is most frequently  used inside switch statement and is part of every case block. Whenever a break is encountered after a case, execution is immediately sent out of switch. Similarily when it is used inside a loop, once break is found, execution comes out of loop. Break statement says, "Exit the loop."

More...

Javascript Conditional Statements - (Learning Javascript Series)

Javascript Conditional Statements

There are two conditional statements in JavaScript: if and switch. The if statement allows the program to choose one of two alternatives, based on some predefined factor.

If statement: It is used to interrupt program flow for some condition.

var num = 10;
                if (num < 20) {
                    alert(num + " is less than 20.");
                }

If - Else: It is used to interupt program flow for some condition but instead of satisfying for one, it will also check for second condition.

var num = 10;
                if (num < 20) {
                    alert(num + " is less than 20.");
                }
                else {
                    alert(num + " is greater than 20.");
                }

More...

Posts By Month