Basic JavaScript Syntax

JavaScript is a powerful programming language with three basic syntax rules, shown in the following table.

Rule

Example

JavaScript is case-sensitive.

Alert is not the same as alert.

Strings must be in quotes.

The following two statements define a variable n as the string Hyperion, and then insert the string value as an argument for the Alert method. The alert says Brio.

var n="Hyperion";
Application.Alert(n);

The following two statements define n without quotes. The alert generates the error Hyperion is not defined because Brio is not a recognized JavaScript term.

var n=Hyperion;
Application.Alert("The company name is "+n);

Legal names (for variables, functions, and objects):

  • Start with a letter and continue with only letters, numbers, or an underscore

  • Do not use reserved words.

  • Must be unique in context.

The first character must be a letter or an underscore(_), not a number. Subsequent characters may be any letter or digit or an underscore, but not a hyphen, period, or space.

sample legal name: _letters123

Names need to be unique in context. An Dashboard section cannot have two drop-down boxes with the same name, a function cannot have two variables with the same name, a document cannot have two sections with the same name

See Reserved Words for a complete list of reserved words.