Resin 1.1
FAQ
Reference
JavaDoc
Demo
Java Tutorial
Getting Started
Configuration
Servlet
JSP
XTP/XSL
JavaScript
JS Library
Source Text
Literals
Regexp
Operators
Objects
Functions
Statements
Java Wrapping
Source Text
Whitespace
JavaScript treats whitespace characters as separators but otherwise ignores them. Additionally, newlines insert automatic semicolons when possible. In either case, a liberal and consistent use of whitespace makes scripts easier to read and more maintainable.
Code | Name
--- | ---
`' ' 0x20` | Space
`'\t' 0x09` | Tab
`'\v' 0x0b` | Vertical Tab
`'\f' 0x0c` | Form Feed (new page)
`'\n' 0x0a` | Newline
`'\r' 0x0d` | Carriage Return
Automatic semicolon insertion
Because newlines naturally separate statements, scripts can often omit the semicolon separator. Scripts must be aware of the automatic semicolons because in a few cases, statements may be unexpectedly separated.
Semicolon insertion for returns
function foo() { return // adds semicolon 3 + 3 // this expression is ignored }
Automatic semicolon insertion with functions
foo // adds semicolon, so foo is (15) // a variable, not a function call.
No automatic semicolon insertion in expression
foo( // no semicolon, so foo(15) is called 15)
No automatic semicolon insertion in `for`
for(var i = 0 // no semicolon inserted here i < 3 // no semicolon inserted here i++) { }
Source encoding
The default source encoding is Latin-1, i.e. ISO-8859-1. Because characters are 16-bits and the source file is 8-bits, the source file is an encoding of the 16-bit characters. The default encoding converts the bytes to the character with the same number, i.e. byte 245 becomes character 245. This poses a problem for languages like Japanese which use all 16 bits. The calling program, e.g. JSP, will set the encoding using a program-specific method.
Setting the encoding in JSP
`<%@ encoding=utf8 %>` <title>Hello, world</title> <h1>Hello, world</h1>
Comments
// single line comment text
Single line comments cause Resin to ignore all text to the end of the line.
/* multiline comment text */
All the multiline comment text is ignored. Multiline comments do not nest.
JavaScript |  | Literals
Copyright © 1998-2000 Caucho Technology. All rights reserved. Last modified: Thu, 16 Sep 1999 14:56:48 -0700 (PDT)