This is the seventh article in a series provided for non-technical System Administrators who wish to understand more about using JavaScript to control workflow and to implement simple customizations using the language.

In this article, I will explore statements in JavaScript.

A program is a sequence of statements.

Expression Statements

And one of the fundamental types is an Expression Statement. An expression is any valid set of literals, variables, operators, and expressions that evaluates to a single value. The value may be a number, a string, or a logical value. 

And any expression that can stand alone as a statement is an Expression statement

strMessage = “hello world”;
myBlock = CRM.GetBlock(“noteboxlong”);

Compound Statements

The next type of statement to understand is a compound statement. These are individual statements that logically must be considered together. We group statements like this using braces { the curly brackets }

Consider the differences between these two examples

Example A

strMessage=“Hello World”;

and this one

Example B

strMessage=“Hello World”;

The set of statements in Example A has an "if" condition. An if condition acts as a guard to the following statement. In this case, if the CRM.Mode evaluates to be in View mode then the second line will be processed. If the CRM.Mode does not evaluate to be in View mode then the line will be skipped.

Importantly the second line which sets the mode to be edit will always be carried out.


When we use the braces we are able to say that both statements must be read together. Everything in a compound statement is treated as a single unit of code.

Arithmetic Operators

JavaScript offers the use of different forms of operators that do ‘work’ on data within statements. Arithmetic operators are used for performing arithmetic tasks on numbers (literals or variables).

And when we are working with variables that are different ways of assigning a value to that variable.

We will meet some of these different types as you explore the articles on the community.

In the next article, I will develop the idea of conditional behaviour and compound statements.