THIRD EDITION
JavaScript
Pocket Reference
David Flanagan
Beijing
•
Cambridge
•
Farnham
•
Köln
•
Sebastopol
•
Tokyo
Downloa d f r o m W o w ! e B o o k < w w w.woweb o o k . c o m >
JavaScript Pocket Reference, Third Edition
by David Flanagan
Copyright © 2012 David Flanagan. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North,
Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promo-
tional use. Online editions are also available for most titles (http://my.safari
booksonline.com). For more information, contact our corporate/institutional
sales department: (800) 998-9938 or corporate@oreilly.com.
Editor: Simon St. Laurent
Production Editor: Teresa Elsey
Proofreader: Kiel Van Horn
Indexer: Jay Marchand
Cover Designer: Karen Montgomery
Interior Designer: David Futato
Illustrator: Robert Romano
October 1998: First Edition.
November 2002: Second Edition.
April 2012: Third Edition.
Revision History for the Third Edition:
2012-04-06 First release
See http://oreilly.com/catalog/errata.csp?isbn=9781449316853 for release de-
tails.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are
registered trademarks of O’Reilly Media, Inc. JavaScript Pocket Reference,
the image of a Javan rhinoceros, and related trade dress are trademarks of
O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish
their products are claimed as trademarks. Where those designations appear
in this book, and O’Reilly Media, Inc., was aware of a trademark claim, the
designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the
publisher and authors assume no responsibility for errors or omissions, or
for damages resulting from the use of the information contained herein.
ISBN: 978-1-449-31685-3
[M]
1333663134
Contents
Preface vii
Chapter 1: Lexical Structure 1
Comments 1
Identifiers and Reserved Words 2
Optional Semicolons 3
Chapter 2: Types, Values, and Variables 5
Numbers 6
Text 9
Boolean Values 12
null and undefined 13
The Global Object 14
Type Conversions 15
Variable Declaration 19
Chapter 3: Expressions and Operators 23
Expressions 24
Operators 28
Arithmetic Operators 32
Relational Operators 36
Logical Expressions 39
iii
Downloa d f r o m W o w ! e B o o k < w w w.woweb o o k . c o m >