Arithmetic operators, String functions, Variables and assignment operators – Multichannel Systems Roboocyte2 JavaScript Manual User Manual
Page 2

Undefined
the value of a variable before it gets a value by
assignment. Occurs in an array when not all members
have been assigned
Arithmetic operators
Mathematical calculations on numbers are made by using the followeing arithmetic operators:
Operator Description
Example
+
addition
y = x + 2;
-
subtraction
y = x – 2;
*
multiplication
y = x * 2;
/
division
y = x / 2;
++
increment by 1, usually used in a
for
loop
i++
--
decrement by 1
i--
String functions
Strings can be manipulated by a number of functions operating on them. The addition operator „+“ has
the meaning of concatenation when used on strings:
Function
Paramters
Description
Example
+ operator
-
concatenation
'up' + 'date'
yields
'update'
length
-
number of characters in the string
var s3 = 'update';
s3.length
is 6
[index]
-
get the character with the given index,
starting at 0
s3[2]
is 'd'
substring
int: startindex,
int: stopindex
returns the substring from startindex to
stopindex
s3.substring(1, 3)
is 'pd'
split
string: separator splits string in a part for each occurence
of separator, returns an aray of the
string parts
var s4 = "a:b:cde:fg:h";
gives an array
indexOf
string: substring returns the index of the first occurence
of the substring, -1 if not found
concat
list of strings
concatenates the string with all strings
in the parameter list
Variables and assignment operators
Variables are used to store values. The value can be retrieved later in the script by using the variable
name. A new variable should be declared with the keyword
var
.
A value is assigned to a name by using an assignment operator (
=
,
+=
,
-=
,
*=
,
/=
). Usually
=
is used,
e.g.
var x = 50;
or
var minimumResult = -50;