Generic filters
Rules applicable to basic syntax in JavaScript

Rules applicable to basic syntax in JavaScript

The following rules apply to the basic syntax of JavaScript:

  • JavaScript is case-sensitive.
  • Statements should end in a semicolon (;).
  • Variables:
    • Must be defined before being used. The variable name can contain A – Z, a – z, underscore or digits and must start with a letter or an underscore (“_”).
    • Assume the type of the data that is put into the variable. The data type does not have to be explicitly defined
    • Are global variables when defined outside of a function, and are available anywhere in the current script context. Variables created within a function are local variables, and can be used only within that function.
  • Strings have to be enclosed in quotation marks, either a single or double. For example: print(”Hello ” + ‘world ‘+ produces the following: Hello world US.
  • Special characters that are displayed literally must be preceded by a backslash character (\). Quotes within a string can be entered preceded by a backslash as well. See the Core Language Features – Literals – “String literals” section for more information in
  • To increment a variable, such as a = a + 1, you can use a++. You can decrement a variable in the same way, as in a–.
  • To enter comments in the script, use “//” to start a single line comment or the combination of “/*” and “*/” to enclose a multi-line comment.
  • Values that are not defined as a data type (string, number, Boolean) may be defined as an object, such as Date, Array, Boolean, String, and Number. As an example you could define: var ArrayList=new Array(”test”, ” this”, ” list”);.
  • Dots in Service Manager field names must be replaced by an underscore (_) in JavaScript. For example becomes contact_name.
  • Service Manager field names that are reserved words in JavaScript have to be preceded by an underscore, such as “_class” for the “class” field.