CybArt's public fiddles
-
Use break statement in while loop
No-Library (pure JS), HTML, CSS, JavaScript
-
Use continue statement in for... in lop
No-Library (pure JS), HTML, CSS, JavaScript
-
Use break statement in for... in loop
No-Library (pure JS), HTML, CSS, JavaScript
-
Use continue statement in a for loop
No-Library (pure JS), HTML, CSS, JavaScript
-
Use break statement in a for loop
No-Library (pure JS), HTML, CSS, JavaScript
-
do... while loop
No-Library (pure JS), HTML, CSS, JavaScript
-
Create and append elements and a child node
No-Library (pure JS), HTML, CSS, JavaScript
-
Use for... in loop to loop through array
The for... in loop can be used for looping through an array with unknown number of elements (even though array.length can be used for teh same purpose in a regular for loop). NOTE the way new DOM elements are created and appended in the loop.
-
Use while loop
Note the use of document.createElement(), document.createTextNode(), and .a[[endChild() methods
-
Use for... in loop to loop through array
The for... in loop can be used for looping through an array with unknown number of elements (even though array.length can be used for teh same purpose in a regular for loop).
-
Use for loop to loop through array
No-Library (pure JS), HTML, CSS, JavaScript
-
Switch statement: Execute the same code for more than one case
No-Library (pure JS), HTML, CSS, JavaScript
-
Switch statement
It is typically used to check a value of one variable.
-
toUpperCase(), toLowerCase()
Note the object-oriented stye, in which these methods have to be implemented. They are used often in comparisons with strings, if there may be an issue with case sensitivity.
-
Use double parentheses for negation operator
You must place the expression that is being negated inside a set of parentheses, and also the entire condition also has to be in parentheses – which results in a double set of parentheses.
-
Omit curly braces if code block contains only one line
Not recommended, for readability reasons.
-
Assign comparison expression to a variable
The value will be either true or false
-
Example of a multidimensional array
No-Library (pure JS), HTML, CSS, JavaScript
-
Create Array as an object with known number of elements
You cannot create an array with just one numeric element, because JavaScript interpreter assumes that it's the number of elements!
-
Create Array as an object, condensed
No-Library (pure JS), HTML, CSS, JavaScript