javascript statements
DESCRIPTION
JavaScript presentation for 24/i, that will touch all JavaScript statements ( ES5 )TRANSCRIPT
![Page 1: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/1.jpg)
![Page 2: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/2.jpg)
JAVASCRIPTSTATEMENTSVictor Perez
![Page 3: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/3.jpg)
/ BLOCK STATEMENT
![Page 4: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/4.jpg)
⁄ ⁄ ⁄
● Delimited by a pair of curly brackets
● Contains one or more statements
● No block scope
○ added in ES6 via let keyword
BLOCKSTATEMENTS
![Page 5: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/5.jpg)
/ CONDITIONAL STATEMENTS
![Page 6: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/6.jpg)
⁄ ⁄ ⁄
● 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
![Page 7: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/7.jpg)
⁄ ⁄ ⁄
● No elseif keyword
NESTED IF...ELSESTATEMENTS
![Page 8: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/8.jpg)
⁄ ⁄ ⁄
● 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
![Page 9: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/9.jpg)
/ LOOP STATEMENTS
![Page 10: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/10.jpg)
⁄ ⁄ ⁄
● 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
![Page 11: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/11.jpg)
⁄ ⁄ ⁄
● Executes a statement at least once and is re-executing it each
time the condition evaluates to true
● Only 1 statement
DO...WHILESTATEMENTS
![Page 12: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/12.jpg)
⁄ ⁄ ⁄
● Executes a statement as long as a specified condition evaluates to
true
● Only 1 statement
WHILESTATEMENTS
![Page 13: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/13.jpg)
⁄ ⁄ ⁄
● 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
![Page 14: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/14.jpg)
⁄ ⁄ ⁄
● 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
![Page 15: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/15.jpg)
⁄ ⁄ ⁄
● 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
![Page 16: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/16.jpg)
⁄ ⁄ ⁄
● 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
![Page 17: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/17.jpg)
/ EXCEPTION HANDLING STATEMENTS
![Page 18: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/18.jpg)
⁄ ⁄ ⁄
● 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
![Page 19: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/19.jpg)
⁄ ⁄ ⁄
● 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
![Page 20: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/20.jpg)
/ FUNCTION STATEMENTS
![Page 21: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/21.jpg)
⁄ ⁄ ⁄
● Declares function with the specified parameters
● You can use the function before you declared it
○ not by function expressions!
FUNCTIONSTATEMENTS
![Page 22: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/22.jpg)
⁄ ⁄ ⁄
● Ends function execution
● Specifies a value to be returned to the function caller
● Default value is undefined
RETURNSTATEMENTS
![Page 23: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/23.jpg)
/ OTHER STATEMENTS
![Page 24: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/24.jpg)
⁄ ⁄ ⁄
● 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
![Page 25: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/25.jpg)
⁄ ⁄ ⁄
● Extends the scope chain for a statement
● Not recommended
● Forbidden in ECMAScript 5 strict mode.
WITHSTATEMENTS
![Page 26: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/26.jpg)
⁄ ⁄ ⁄
● Is used to provide no statement, where the syntax requires one
EMPTYSTATEMENTS
![Page 27: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/27.jpg)
/ QUESTIONS?
![Page 28: JavaScript statements](https://reader034.vdocument.in/reader034/viewer/2022052600/5578182ad8b42ab40c8b4b21/html5/thumbnails/28.jpg)
THANKS@[email protected]