CybArt's public fiddles
-
Any named argument that is not passed into the function is assigned undefined
No-Library (pure JS), HTML, CSS, JavaScript
-
Values of arguments object are synced with the values of the corresponding named parameters.
That's why in this example, the value of a named parameter gets replaced with the value of an arument
-
arguments object can be used in conjunction with named arguments
No-Library (pure JS), HTML, CSS, JavaScript
-
Function performs different tasks depending on the number of arguments, PArt 3 (a better switch statement)
No-Library (pure JS), HTML, CSS, JavaScript
-
Function that performs different tasks depending on the number of arguments, Part 2 (using swicth instead of if / else)
No-Library (pure JS), HTML, CSS, JavaScript
-
A function that performs different tasks depending on a number of arguments it has received
No-Library (pure JS), HTML, CSS, JavaScript
-
Using arguments.length to return positive integers, Version 2 (improved)
No-Library (pure JS), HTML, CSS, JavaScript
-
Use arguments.length to generate numbers
No-Library (pure JS), HTML, CSS, JavaScript
-
Named arguments in JS functions are not obligatory, but a matter of convenience
No-Library (pure JS), HTML, CSS, JavaScript
-
Return statemnt can be used without specifying the return value.
No-Library (pure JS), HTML, CSS, JavaScript
-
If encapuslate each return statement withn its own sttement block inside the function – youc an have multiple return statements in one function!
No-Library (pure JS), HTML, CSS, JavaScript
-
A return statement after a retunr statement won't execute, either
No-Library (pure JS), HTML, CSS, JavaScript
-
Anthing within a function after return statement will not execute
No-Library (pure JS), HTML, CSS, JavaScript
-
The return statement in functions
No-Library (pure JS), HTML, CSS, JavaScript
-
Fin with prompt, function and if / else
No-Library (pure JS), HTML, CSS, JavaScript
-
A much better example of a JavaScript function
No-Library (pure JS), HTML, CSS, JavaScript
-
An example of a JavaScript function
No-Library (pure JS), HTML, CSS, JavaScript
-
You can use case expressions in switch statements
No-Library (pure JS), HTML, CSS, JavaScript
-
Swicth statement in JS has unique traits
It works with all data types (not only with numbers, like in some other languages; it can even be used with objects. Also, the case values need not be constants: they can be variables and even expressions.
-
A fall-through in a switch statement
If a break statement is omitted on purpose in the switch statement (a technique known as "fall-through") it should be considered best practice to make a comment, so that a code reader knows the fall-through was NOT unintentional