Please enable JavaScript to view this site.

Knowledge Bridge Documentation

Help version: 3.3.8

 

NOTE: If you are familiar with JavaScript, jump to the next topic.

 

The JavaScript family of development languages (JS) comprise one of the basic development environments employed for deployment on the World Wide Web. JS is ubiquitous—that is, it is found on nearly every Web site and enabled in all browsers worthy of the name.

 

There are well-defined standards around JavaScript"s syntax and capabilities.

 

JS is an interpreted language—that is, it executes instructions directly. It does not require compiling into machine-language instructions.

 

Formatting: punctuation, symbols, brackets

As an interpreted language, JS depends on your formatting and inclusion of specific punctuation to provide the JS interpreter with clues about the intent of the code being presented to it. You need to be careful about entering code—that is the reality of JS.

 

Punctuation and symbols

Double forward slash: // indicates a comment. Multi-line comments are started with /* and ended with */. Example:

// I am a comment

/* 

 I am also

 a comment

*/

 

Semicolons: end statements. Statements are a complete instruction to the interpreter and the semicolon separates these instructions. Example:

int a;                // Declaration statement

a = 30;                // Assignment statement

println(i);        // Function statement

 

Commas are used to separate a list of variable declarations, a list of variable values, or a list of Parameters passed to a function. Examples:

int a=20, b=30, c=80;

int[] d = { 20, 60, 80 };

line (a, b, c, b);

 

Brackets

Parentheses send and receive variables, group expressions, and contain a list of Parameters. Example:

a = (4 + 3) * 2;        //grouping; this example ensures that 4 and 3 are summed prior to multiplication by 2

if (a > 10)                 //containing expressions, in this case, "if a is greater than 10"

line (a, 0, a, 100)        // list of Parameters (the line spans from 1 to 100)

 

Square brackets indicate a slot in an array, AKA "array access operator." Example:

int[] numbers = new int[3]                //Sets "numbers" to an array of 3 integers

numbers [0] = 90;                        // sets the first numbers is 90

numbers [1] = 150;                        // second numbers is 150

numbers [3] = 30;                        // third numbers is 30

int a = numbers[0] + numbers[1];        // Sets variable a to 240

int b = numbers[1] + numbers[2};        // Sets variable a to 180

 

Curly brackets define and start and end of a function, define initial values in an array, and separate blocks of code in a function. Example:

var language = {                //this example shows both start/end of the "language" function and separation of blocks of code

 set current(name) {

         this.log.push(name);

 },

 log: []

}        

 

int[] a = { 5, 20, 25, 45, 70 };

 

An opened bracket requires closing

If you begin an expression with, say, an open parenthesis, you must supply a close parenthesis at the end of the expression.

Knowledge Bridge from Engingeering Intent is a full-featured engineering and sales automation environment