Book description
Like it or not, JavaScript is everywhere these days—from browser to server to mobile—and now you, too, need to learn the language or dive deeper than you have. This concise book guides you into and through JavaScript, written by a veteran programmer who once found himself in the same position.
Speaking JavaScript helps you approach the language with four standalone sections. First, a quick-start guide teaches you just enough of the language to help you be productive right away. More experienced JavaScript programmers will find a complete and easy-to-read reference that covers each language feature in depth. Complete contents include:
- JavaScript quick start: Familiar with object-oriented programming? This part helps you learn JavaScript quickly and properly.
- JavaScript in depth: Learn details of ECMAScript 5, from syntax, variables, functions, and object-oriented programming to regular expressions and JSON with lots of examples. Pick a topic and jump in.
- Background: Understand JavaScript’s history and its relationship with other programming languages.
- Tips, tools, and libraries: Survey existing style guides, best practices, advanced techniques, module systems, package managers, build tools, and learning resources.
Table of contents
- Praise for Speaking JavaScript
- Preface
- I. JavaScript Quick Start
- II. Background
-
III. JavaScript in Depth
-
7. JavaScript’s Syntax
- An Overview of the Syntax
- Comments
- Expressions Versus Statements
- Control Flow Statements and Blocks
- Rules for Using Semicolons
- Legal Identifiers
- Invoking Methods on Number Literals
-
Strict Mode
- Switching on Strict Mode
- Strict Mode: Recommended, with Caveats
- Variables Must Be Declared in Strict Mode
- Functions in Strict Mode
- Setting and Deleting Immutable Properties Fails with an Exception in Strict Mode
- Unqualified Identifiers Can’t Be Deleted in Strict Mode
- eval() Is Cleaner in Strict Mode
- Features That Are Forbidden in Strict Mode
- 8. Values
-
9. Operators
- Operators and Objects
- Assignment Operators
- Equality Operators: === Versus ==
- Ordering Operators
- The Plus Operator (+)
- Operators for Booleans and Numbers
- Special Operators
- Categorizing Values via typeof and instanceof
- Object Operators
- 10. Booleans
-
11. Numbers
- Number Literals
- Converting to Number
- Special Number Values
- The Internal Representation of Numbers
- Handling Rounding Errors
- Integers in JavaScript
- Converting to Integer
- Arithmetic Operators
- Bitwise Operators
- The Function Number
- Number Constructor Properties
- Number Prototype Methods
- Functions for Numbers
- Sources for This Chapter
- 12. Strings
- 13. Statements
- 14. Exception Handling
-
15. Functions
- The Three Roles of Functions in JavaScript
- Terminology: “Parameter” Versus “Argument”
- Defining Functions
- Hoisting
- The Name of a Function
- Which Is Better: A Function Declaration or a Function Expression?
- More Control over Function Calls: call(), apply(), and bind()
- Handling Missing or Extra Parameters
- Named Parameters
-
16. Variables: Scopes, Environments, and Closures
- Declaring a Variable
- Background: Static Versus Dynamic
- Background: The Scope of a Variable
- Variables Are Function-Scoped
- Variable Declarations Are Hoisted
- Introducing a New Scope via an IIFE
- Global Variables
- The Global Object
- Environments: Managing Variables
- Closures: Functions Stay Connected to Their Birth Scopes
-
17. Objects and Inheritance
- Layer 1: Single Objects
- Converting Any Value to an Object
- this as an Implicit Parameter of Functions and Methods
- Layer 2: The Prototype Relationship Between Objects
- Iteration and Detection of Properties
- Best Practices: Iterating over Own Properties
- Accessors (Getters and Setters)
- Property Attributes and Property Descriptors
- Protecting Objects
- Layer 3: Constructors—Factories for Instances
- Data in Prototype Properties
- Keeping Data Private
-
Layer 4: Inheritance Between Constructors
- Inheriting Instance Properties
- Inheriting Prototype Properties
- Ensuring That instanceof Works
- Overriding a Method
- Making a Supercall
- Avoiding Hardcoding the Name of the Superconstructor
- Example: Constructor Inheritance in Use
- Example: The Inheritance Hierarchy of Built-in Constructors
- Antipattern: The Prototype Is an Instance of the Superconstructor
- Methods of All Objects
- Generic Methods: Borrowing Methods from Prototypes
- Pitfalls: Using an Object as a Map
- Cheat Sheet: Working with Objects
-
18. Arrays
- Overview
- Creating Arrays
- Array Indices
- length
- Holes in Arrays
- Array Constructor Method
- Array Prototype Methods
- Adding and Removing Elements (Destructive)
- Sorting and Reversing Elements (Destructive)
- Concatenating, Slicing, Joining (Nondestructive)
- Searching for Values (Nondestructive)
- Iteration (Nondestructive)
- Pitfall: Array-Like Objects
- Best Practices: Iterating over Arrays
-
19. Regular Expressions
- Regular Expression Syntax
- Unicode and Regular Expressions
- Creating a Regular Expression
- RegExp.prototype.test: Is There a Match?
- String.prototype.search: At What Index Is There a Match?
- RegExp.prototype.exec: Capture Groups
- String.prototype.match: Capture Groups or Return All Matching Substrings
- String.prototype.replace: Search and Replace
- Problems with the Flag /g
- Tips and Tricks
- Regular Expression Cheat Sheet
- 20. Dates
- 21. Math
- 22. JSON
- 23. Standard Global Variables
- 24. Unicode and JavaScript
- 25. New in ECMAScript 5
-
7. JavaScript’s Syntax
-
IV. Tips, Tools, and Libraries
- 26. A Meta Code Style Guide
- 27. Language Mechanisms for Debugging
- 28. Subclassing Built-ins
- 29. JSDoc: Generating API Documentation
- 30. Libraries
- 31. Module Systems and Package Managers
- 32. More Tools
- 33. What to Do Next
- Index
- About the Author
- Colophon
- Copyright
Product information
- Title: Speaking JavaScript
- Author(s):
- Release date: February 2014
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781449364991
You might also like
book
Rails, Angular, Postgres, and Bootstrap
As a Rails developer, you care about user experience and performance, but you also want simple …
book
JavaScript Frameworks for Modern Web Development: The Essential Frameworks, Libraries, and Tools to Learn Right Now
Enrich your software design skills and take a guided tour of the wild, vast, and untamed …
book
Get Programming with JavaScript
Get Programming with JavaScript is a hands-on introduction to programming for readers who have never programmed. …
video
GenAI Essentials for Everyone - Overview
Our team of experts has hand-selected and organized the most crucial concepts and practical applications of …