Presentation is loading. Please wait.

Presentation is loading. Please wait.

Expressions and Control Flow in JavaScript

Similar presentations


Presentation on theme: "Expressions and Control Flow in JavaScript"— Presentation transcript:

1 Expressions and Control Flow in JavaScript
How to construct complex expressions in JavaScript and how to control the program flow of your scripts using conditional statements

2 Expressions An expression is a combination of values, variables, operators, and functions that results in a value; the result can be a number, a string, or a Boolean value (which evaluates to either true or false).

3 Boolean Expressions

4 Literals and Variables

5 Operators

6 Operator Precedence

7 Associativity Most JavaScript operators are processed in order from left to right in an equation

8 Relational Operators, Equality Operators
Test two operands and return a Boolean result of either true or false. There are three types of relational operators: equality, comparison, and logical

9 The equality and identity operators

10 Comparison operators

11 Logical operators

12 The with Statement You can simplify some types of JavaScript statements by reducing many references to an object to just one reference

13 Using onError

14 Conditionals, The if Statement

15 The else statement

16 The switch Statement

17 The switch Statement

18 Breaking out, Default action
break command allows your code to break out of the switch statement once a condition has been satisfied you can specify a default action for a switch statement using the default keyword.

19 The ? Operator The ternary operator (?), combined with the : character, provides a quick way of doing if...else tests

20 Looping, while Loops Both languages support while, do...while, and for loops. Upon completing an iteration of the loop, the expression is again tested to see if it is true and the process continues until such a time as the expression evaluates to false

21 do...while Loops When you require a loop to iterate at least once before any tests are made, use a do...while loop,

22 for Loops, Breaking Out of a Loop
An initialization expression A condition expression A modification expression When searching for a match of some kind. Once the match is found, you know that continuing to search will only waste time and make your visitor wait

23 The continue Statement

24 Explicit Casting


Download ppt "Expressions and Control Flow in JavaScript"

Similar presentations


Ads by Google