Console Learner — An interactive JavaScript course.

3.1 Named Functions

The following terms will be used henceforth:

Any number of arguments can be supplied in the function call. Either too few and too many. It is therefore prudent to check the input arguments for errors or invalid types.
Return values are optional in JavaScript. The default return value is always undefined.
Side-effects are common in JavaScript functions, such as web page modifications or similar. There is no distinction between functions with side-effects and those without.
function hello(name) {
    return "Hello, " + name + "!";

A function with a single argument. The arguments are variables visible only inside the function. A return statement stops execution and immediately returns a value.
"Hello, world!"
A function is called with the name followed by a parenthesized list of argument values. Each argument is separated with a comma, e.g. (arg1, arg2, ...).
"Hello, undefined!"
Any number of arguments can be provided in a function call. The declared arguments without a value are initiated to undefined.
function add(a, b) {
    return a + b;

add(1, 2)
add('1', '2')
As the add() function performed no type checking, it can be re-purposed for concatenating strings...

The console allows you to interact with the course material and examples. Use the following keys:

A special logging function is also available:

Need more magic? Check out the other developer tools on this site.