Rx4AJAX   (Prescription for AJAX)

ECMA-262/Core JavaScript

ECMA-262/Core JavaScript





ECMA-262 Core: An Overview of JavaScript Operators


Definition of Operators

Operators are keywords or symbols in expressions that perform an operation. The operation is performed on values that are left and/or right of the operator as they exist in the expression. The operation by the operator will produce a new value for the expression. The input values of the operator are called operands. The output value that the operator arrives at is the result. An operator may require one, two or three operands. An operator in the unary group will require but one operand. Likewise, the binary group requires two operands and a ternary operator require three operands.

To summarize: The input values (operands) to operators are simple expressions. These simple expressions along with the operator combine to make a complex expression. The complex expression will be evaluated and the result is the output value of the operation.

Operators and Simple Expressions

Operators combine with simple expressions to form more complex expressions. The ECMAScript Language Specification section 11 is entitled "Expressions". However, the majority of section 11 pertains to operators. An operator by itself does nothing. But when combined with operands, they perform an operation.

Operators are Denoted with Symbols

Most operators are denoted with symbols. But, some operators are keywords such as: void, delete, typeof, in and instanceof. Many operator symbols are the same symbols you used in your math and algebra classes. If you have programmed before, you will be familiar with most of the JavaScript operator symbols. To view the JavaScript operator symbols, take this link: Operator Precedence Table

Operators and Precedence

All operators have a pre-defined execution priority or precedence. Within a given complex expression, operations will be performed in order of priority. One operation will proceed before another when it has precedence in the operator priority scheme. Javascript operators have 15 levels of priority. Note that we choose a precedence scale where 15 indicates the highest precedence and 1 is the lowest. Be aware that some reference sources will reverse this scale where 1 is the highest precedence and 15 the lowest. Go Directly to Operator Precedence Table.

Operators and Associativity

The associativity of an operator specifies the order in which operations are performed in an expression where two or more operators are of the same precedence. When an expression has two or more operators with the same precedence, then the operation will proceed either right-to-left or left-to-right depending on the associativity of the operators. Where an expression has only one operator or all operators are of a different precedence, then associativity does not come into play.

Operators and Operands

Each operator has a predefined number of operands. Operators with only one operand belong to the unary operator group. Depending on the operator, this single operand can be either to the left or to the right of the operator. Operators with two operands are referred to as binary operators. The conditional operator is the only JavaScript operator that takes three operands (ternary operator).

Types of Operands

The data that is expected by operators is encoded in the operator's operands. The nature of the operand data will vary depending on the operator. The operand data will normally conform to a JavaScript data type. See our separate page on "Operator Operands and Their Data Types" for a summary and cross reference of operators and their operand types.

Types of Results

All operators perform an operation. Operators are embedded in expressions. Most expressions arrive at an additional value or action that is apart from the original operand(s). However, other expressions with certain operators will actually alter the value of one of the operands (they have a side effect).

To summarize, some operations return a value and other operations cause side effects. If this aspect of operators is of interest, you can link to a summary of types of results from operator operations.

Operator Groups

With a couple exceptions, the operator groups we address here conform to the groupings described in Section 11 of the ECMAScript Language Specification. Here are the operator groups and links to a discussion pertaining to each group.

ECMAScript - Section 11

Section 11 is entitled "Expressions". This is the section where operators are specified in the ECMAScript Language Specification. We have built a reference table that summarizes section 11. Go Directly our page giving a ECMAScript Section 11 Synopsis.

Notes

The in group is our term. The in group contains the in operator and the instanceof operator. They both are part of the Relational Operator Group in section 11.8. These two operators pertain to objects, unlike the rest of the relational operator set. They are similar in that they return boolean values, otherwise, they are unique.

The Access group is also our term. The Access group contains the dot operator, bracket operator, parentheses operator and the new operators. These operators pertain to the complex data types of the generic object types (arrays, functions and objects).

Top            


Rx4AJAX        About Us | Topic Index | Contact Us | Privacy Policy | 2008 This Site Built By PPThompson