Content deleted Content added
No edit summary |
relevant wikilinks |
||
Line 13:
===Case sensitivity===
JavaScript is [[Case sensitivity|case sensitive]]. It is common to start the name of a [[Constructor (computer science)|constructor]] with a [[CamelCase|capitalised]] letter, and the name of a function or variable with a lower-case letter.
Example:
Line 24:
===Whitespace and semicolons===
[[Space (punctuation)|Space]]s, [[tab character|tab]]s and [[newline]]s used outside of string constants are called [[whitespace (computer science)|whitespace]]. Unlike in [[C (programming language)|C]], whitespace in JavaScript source can directly impact [[Semantics (computer science)|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.<ref>{{cite book
|title=JavaScript: The definitive Guide
|last=Flanagan
Line 35:
There are two issues: five tokens can either begin a statement or be the extension of a complete statement; and five restricted productions, where line breaks are not allowed in certain positions, potentially yielding incorrect parsing.<ref name="inimino" />
The five problematic tokens are the open parenthesis "<tt>(</tt>", open bracket "<tt>[</tt>", slash "<tt>/</tt>", plus "<tt>+</tt>", and minus "<tt>-</tt>". Of these, the open parenthesis is common in the [[immediately-invoked function expression]] pattern, and open bracket occurs sometimes, while others are quite rare. The example given in the spec is:<ref name="inimino" />
<syntaxhighlight lang="javascript">
|