|
JavaScript 2.0
Core Language
Expressions
|
Thursday, November 11, 1999
Most of the behavior of expressions is the same as in JavaScript 1.5. Differences are highlighted below. One general difference is that most expression operators can be overridden via operator overloading.
boxconstructorfieldgetlanguagelocalmethodsetoverrideversionThe above keywords are not reserved and may be used in identifiers.
Just like in ECMAScript Edition 3, an identifier evaluates to an internal data structure called a reference. However, JavaScript 2.0 references have several additional attributes, one of which is a namespace. The namespace is set to the value of the ParenthesizedExpression. If the ParenthesizedExpression is a simple Identifier or QualifiedIdentifier then the parentheses may be omitted.
nulltruefalsethissuper? IdentifierA Number literal or ParenthesizedExpression
followed by a String literal is a unit expression. The unit object specified by the String
is looked up; the result is called as a function and passed two arguments: the numeric value of the Number
literal or ParenthesizedExpression, and either null
(if a ParenthesizedExpression was provided) or the original
Number literal expressed as a string.
The string representation allows user-defined unit classes to define extended syntaxes for numbers. For instance, a long-integer
package might define a unit called "L" that treats the Number literal as
a full 64-bit number without rounding it to a double first.
A ? Identifier expression
is used to access scope information.
++--The @ operator performs a type cast. The second operand specifies the type. Both the
. and the @ operators accept either a QualifiedIdentifier
or a ParenthesizedExpression as the second operand.
If it is a ParenthesizedExpression, the second operand
of . must evaluate to a string. a.(x) is a synonym for a[x]
except that the latter can be overridden via operator overloading.
The [] operator can take multiple (or even named) arguments. This allows users to define
data structures such as multidimensional arrays via operator overloading.
An ArgumentList can contain both positional and named arguments. Named arguments use the same syntax as object literals.
delete PostfixExpressiontypeof UnaryExpressioneval UnaryExpression++ PostfixExpression-- PostfixExpression+ UnaryExpression- UnaryExpression~ UnaryExpression! UnaryExpressionThe ^^ operator is a logical exclusive-or operator. It evaluates both operands. If
they both convert to true or both convert to false, then ^^ returns false; otherwise ^^
returns the unconverted value of whichever argument converted to true.
|
Waldemar Horwat Last modified Thursday, November 11, 1999 |