*** Welcome to piglix ***

Variable hoisting


The syntax of JavaScript is the set of rules that define a correctly structured JavaScript program.

The examples below make use of the log function of the console object present in most browsers for standard text output.

The JavaScript standard library lacks an official standard text output function. Given that JavaScript is mainly used for client-side scripting within modern Web browsers, and that almost all Web browsers provide the alert function, alert can also be used, but is not commonly used.

Brendan Eich summarized the ancestry of the syntax in the first paragraph of the JavaScript 1.1 specification as follows:

JavaScript borrows most of its syntax from Java, but also inherits from Awk and Perl, with some indirect influence from Self in its object prototype system.

JavaScript is case sensitive. It is common to start the name of a constructor with a capitalised letter, and the name of a function or variable with a lower-case letter.

Example:

Spaces, tabs and newlines used outside of string constants are called whitespace. Unlike C, whitespace in JavaScript source can directly impact semantics. Because of a technique called "automatic semicolon insertion" (ASI), some statements that are well formed when a newline is parsed will be considered complete (as if a semicolon were inserted just prior to the newline). Some authorities advise supplying statement-terminating semicolons explicitly, because it may lessen unintended effects of the automatic semicolon insertion.


...
Wikipedia

...