**JavaScript Tutorials - Herong's Tutorial Examples** - Version 2.21, by Dr. Herong Yang

Operators and Expressions

This section provides descriptions on operators and expressions, including arithmetic, comparison, logical, bitwise, and assignment operators.

**What are expressions?**
Expressions are sequences of literals, variables, and operators that can be evaluated to values.

Operators are the most important parts of expressions. JavaScripts many basic operators divided into several groups:

1. Arithmetic Operator - Taking numeric values and returning a single numeric value. Arithmetic operators include addition (+), subtraction (-), multiplication (*), and division (/), modulus (%), increment (++), decrement (--), and unary negation (-).

2. Comparison Operator - Taking values of any types and returning a single boolean value. Comparison operators include equal (==), not equal (!=), strict equal (===), strict not equal (!==), greater than (>), greater than or equal (>=), less than (<), and less than or equal (<=).

3. Logical Operator - Taking boolean values and returning a single boolean value. Logical operators include logical AND (&&), logical OR (||), and logical NOT (!).

4. Bitwise Operator - Taking bit strings of 32 bits and returning a single numeric value. Bitwise operators include bitwise AND (&), bitwise OR (|), bitwise XOR (^), bitwise NOT (~), left shift (<<), sign-propagating right shift (>>), and zero-fill right shift (>>>).

5. Assignment Operator - Taking a value of any type and returning a single value. An assignment operator assigns a value to its left operand based on the value of its right operand. Assignment operators include simple assignment (=), assignments combined with arithmetic operators (+=, -=, *=, /=, %=), and assignments combined with bitwise operators (&=, ^=, |=, <<=, >>=, >>>=).

A tutorial example will be given in the next section showing examples of different operators and expressions.

Table of Contents

ECMAScript Language Specification and JavaScript Dialects

►Data Types, Variables and Expressions

Primitive Data Types - Numbers, Strings, and Booleans

Declaring Variables - "var" Statements

Operators and Expressions - Examples

Creating, Accessing, and Manipulating Arrays

Defining and Calling Functions

Web Browser Supporting JavaScript

Server-Side and Client-Side Web Scripting

Defining Your Own Object Types

Inheritance of Properties and Methods through the Prototype Object Chain

'jrunscript' - JavaScript Shell Command from JDK

Using Functions as "Function" Objects

Introduction to Built-in Object Types