JavaScript/Helpful hints

Predefined functions
All over the Wikibook, code examples are given. Usually, they show their results somewhere in the browser. This is done via methods that are aligned with Web API interfaces and implemented in browsers.

The function  creates a modal window showing the given text.

The function  writes the message to the console of the browser. The console is a window of the browser that is normally not opened. In most browsers, you can open the console via the function key.

The function  opens the print dialog to print the current document.

The function  opens a modal window and reads the user input.

The use of  is strongly discouraged.

Coding style
Our code examples mostly contain the line  before any other statement. This advises the compiler to perform additional lexical checks. He especially detects the use of variable names which are not been declared before they receive a value.

Without the  statement the compiler would generate a second variable with the misspelled name instead of generating an error message.

Faulty visualization in some code examples
Due to a minor fault in the Wikibook template quiz, you will see  instead of   in some examples. The two slashes at the end are only shown to overcome this problem; they are not necessary.