CybArt's public fiddles
-
Switch statement
No-Library (pure JS), HTML, CSS, JavaScript
-
The with statement
The with statement sets the scope of the code within a particular object. Keep in miond that in strict mode the with statement is not allowed, and is considered an error
-
Using labeled statement together with continue statement
In this case, thanks to using a label, the continue statement tells the execution to continue not in the inner loop, but in the outer loop.
-
Using labeled statement together with break statement
The break statement here is given one argument: the label to break to. Adding the label allows the break statement to break not only out of the inner for statement, but also of the outer for statement (labeled as outermost: )
-
Continue statement
The continue statement exits the loop immediately, but execution continues from the top of the loop
-
Break statement
Te break statement exists the loop immediately, forcing the execution to continue starting with the next statement after the loop
-
Labeled Statements
You can label statements for later use in JavaScript! Its done by by attaching the label before the statement, followed by the colon. Labeled statements are typically used with nested loops
-
How to pull keys and / or values from an object
No-Library (pure JS), HTML, CSS, JavaScript
-
Proper way to loop through an object uinsg for... in loop
check for the object not being equal to null or undefined before attempting to loop through it
-
The for-in statement
This statement is used to enumerate the properties of an object.
-
Similarity between for and while statements
Including only the control expression, and omitting both initialization and postloop expression, turns the for loop into a while loop
-
Initialization, control expression, and postloop expression are optional
Omitting all three is possible, but results in an infinite loop
-
Proof that there are no block-scoped variables in ECMAScript
A variable initialized inside the for statement is available outside of the statement.
-
The for statement with variables initialized outside
No-Library (pure JS), HTML, CSS, JavaScript
-
The for Statement
No-Library (pure JS), HTML, CSS, JavaScript
-
A better example of do... while statement
No-Library (pure JS), HTML, CSS, JavaScript
-
do ... while statement (aka do... while loop)
The do... while statement is a "post-test" loop (the test condition is being evaluated only after the code inside the loop has executed)
-
if - else if - else statement
No-Library (pure JS), HTML, CSS, JavaScript
-
if statement
No-Library (pure JS), HTML, CSS, JavaScript
-
A rare way to use comma operator
In this example, myNum is asisgned the value of 0 because it is the last item in the expression. There aren't many times when commas are used in that way, however it is helpful to understand that this behavior exists.