Upload
victor-verhaagen
View
216
Download
0
Tags:
Embed Size (px)
DESCRIPTION
JavaScript presentation for 24/i, that will touch all JavaScript statements ( ES5 )
Citation preview
JAVASCRIPTSTATEMENTSVictor Perez
/ BLOCK STATEMENT
⁄ ⁄ ⁄
● Delimited by a pair of curly brackets
● Contains one or more statements
● No block scope
○ added in ES6 via let keyword
BLOCKSTATEMENTS
/ CONDITIONAL STATEMENTS
⁄ ⁄ ⁄
● Executes a statement if the condition is true
● Executes the optional second statement if the condition is false
● Both if and else can only have 1 statement
IF...ELSESTATEMENTS
⁄ ⁄ ⁄
● No elseif keyword
NESTED IF...ELSESTATEMENTS
⁄ ⁄ ⁄
● Compares the expression agans all case expressions using strict equal
● Execution of the statements will start by the first matching case clause.
● break statement forces the program to break out of the switch
● default case expressions will always be executed
SWITCHSTATEMENTS
/ LOOP STATEMENTS
⁄ ⁄ ⁄
● Executes a statement as long the condition is true
● Variable declaration in the initialization are in the
same scope as the for loop
● An empty condition always evaluates to true
● Only 1 statement
FORSTATEMENTS
⁄ ⁄ ⁄
● Executes a statement at least once and is re-executing it each
time the condition evaluates to true
● Only 1 statement
DO...WHILESTATEMENTS
⁄ ⁄ ⁄
● Executes a statement as long as a specified condition evaluates to
true
● Only 1 statement
WHILESTATEMENTS
⁄ ⁄ ⁄
● Iterates over the enumerable properties of an object
● On each iteration, a different property name is assigned to variable
● Arbitrary order
● Only 1 statement
● Don’t use it for array’s!
FOR...INSTATEMENTS
⁄ ⁄ ⁄
● Label a statement
● The labeled statement can be used with break or continue
statements.
● Label can be any valid JavaScript identifier
● Avoid using labels!
LABELSTATEMENTS
⁄ ⁄ ⁄
● Terminates the current loop, switch, or label statement
● Label is only optional if the break is used in a loop or switch, else its
required
BREAKSTATEMENTS
⁄ ⁄ ⁄
● Terminates execution of the statements in the current iteration of the
current loop
● Jumps to the final-expression of a for loop
● Jumps to the condition of a while loop
CONTINUESTATEMENTS
/ EXCEPTION HANDLING STATEMENTS
⁄ ⁄ ⁄
● Throws a user-defined exception
● The statements after throw won't be executed
● Will execute the first catch block in the call stack
● Will terminate the program if there is not catch block in the full call
stack
THROWSTATEMENTS
⁄ ⁄ ⁄
● Try block marks a block of statements to try
● Catch clause specifies a response, should an exception be thrown
● Finally clause executes after the try block and catch clause
TRY...CATCHSTATEMENTS
/ FUNCTION STATEMENTS
⁄ ⁄ ⁄
● Declares function with the specified parameters
● You can use the function before you declared it
○ not by function expressions!
FUNCTIONSTATEMENTS
⁄ ⁄ ⁄
● Ends function execution
● Specifies a value to be returned to the function caller
● Default value is undefined
RETURNSTATEMENTS
/ OTHER STATEMENTS
⁄ ⁄ ⁄
● Invokes any available debugging functionality
● This statement has no effect, if there is no debugger functionality available
● Execution is paused at the debugger statement
DEBUGGERSTATEMENTS
⁄ ⁄ ⁄
● Extends the scope chain for a statement
● Not recommended
● Forbidden in ECMAScript 5 strict mode.
WITHSTATEMENTS
⁄ ⁄ ⁄
● Is used to provide no statement, where the syntax requires one
EMPTYSTATEMENTS
/ QUESTIONS?
THANKS@[email protected]