Skip to Content
JavaScript: The Definitive Guide, Fourth Edition
book

JavaScript: The Definitive Guide, Fourth Edition

by David Flanagan
November 2001
Intermediate to advanced
936 pages
68h 43m
English
O'Reilly Media, Inc.
Content preview from JavaScript: The Definitive Guide, Fourth Edition

Operator Overview

If you are a C, C++, or Java programmer, most of the JavaScript operators should already be familiar to you. Table 5-1 summarizes the operators; you can refer to this table for reference. Note that most operators are represented by punctuation characters such as + and =. Some, however, are represented by keywords such as delete and instanceof. Keyword operators are regular operators, just like those expressed with punctuation; they are simply expressed using a more readable and less succinct syntax.

In this table, the column labeled “P” gives the operator precedence and the column labeled “A” gives the operator associativity, which can be L (left-to-right) or R (right-to-left). If you do not already understand precedence and associativity, the subsections that follow the table explain these concepts. The operators themselves are documented following that discussion.

Table 5-1. JavaScript operators

P

A

Operator

Operand type(s)

Operation performed

15

L

.

object, identifier

Property access

L

[]

array, integer

Array index

L

( )

function, arguments

Function call

R

new

constructor call

Create new object

14

R

++

lvalue

Pre- or post-increment (unary)

R

--

lvalue

Pre- or post-decrement (unary)

R

-

number

Unary minus (negation)

R

+

number

Unary plus (no-op)

R

~

integer

Bitwise complement (unary)

R

!

boolean

Logical complement (unary)

R

delete

lvalue

Undefine a property (unary)

R

typeof ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

JavaScript: A Beginner's Guide, Fourth Edition, 4th Edition

JavaScript: A Beginner's Guide, Fourth Edition, 4th Edition

John Pollock
JavaScript Cookbook, 3rd Edition

JavaScript Cookbook, 3rd Edition

Adam D. Scott, Matthew MacDonald, Shelley Powers

Publisher Resources

ISBN: 0596000480Supplemental ContentCatalog PageErrata