Functions, Further reading – Multichannel Systems Roboocyte2 JavaScript Manual User Manual
Page 5

–
shift()
: move all values to their previous position, thereby removing the first element and
shortening the length by 1
–
join(connecting string)
: connects the values of the array with the argument and returns a
string
Functions
Functions are a very powerful concept in JavaScript. Here only the most basic features are
documented.
Functions can be used to hold code, which is used for a specific purpose, in a separate block. This
make it much easier to maintain a clear structure in the script code, especially when the function is
used in several different places.
Functions are defined via the keyword function, followed by the user defined function name and a
code block. The function definition also specifies parameters. These are names for values which are
used when the function code is executed. The code of the function is executed by calling it with the
given name and the concrete values of the parameters.
If a variable is declared with the keyword
var
inside the function code block, it is local to the function
and can not be referenced from other code.
Example function definition:
function square(x) {
return x * x;
}
To execute the code with actual parameter values:
var squared = square(2);
Further Reading
There are many tutorials and references about JavaScript to be found on the internet, a few of them are
listed below. Remember that only the JavaScript syntax is used, all web specific elements are not
supported, so in the tutorials all references to HTML, especially tags and the document object, to the
DOM model, to events and to web pages must be ignored.