0%

Book Description

JavaScript Absolute Beginner's Guide serves as an easy-to-understand tutorial on both scripting basics and JavaScript itself. The book is written in a clear and very personable style with an extensive use of practical, complete examples. The book is filled with large, full-color illustrations and all the programming code is displayed in color to help the beginner understand the key components and structure of the language.

Table of Contents

  1. Cover Page
  2. About This eBook
  3. Title Page
  4. Copyright Page
  5. Contents at a Glance
  6. Register Your Book
  7. Table of Contents
  8. Dedication
  9. Acknowledgments
  10. About the Author
  11. Figure Credits
  12. Introduction
    1. Parlez-vous JavaScript?
    2. Contacting Me/Getting Help
  13. 1. Hello, World!
    1. What Is JavaScript?
    2. Hello, World!
    3. Looking at the Code: Statements and Functions
  14. Part I: The Basic Stuff
    1. 2. Values and Variables
      1. Using Variables
      2. More Variable Stuff
    2. 3. Functions
      1. What Is a Function?
      2. A Simple Function
      3. Creating a Function that Takes Arguments
      4. Creating a Function that Returns Data
    3. 4. Conditional Statements: if, Else, and Switch
      1. The If / Else Statement
      2. Switch Statements
      3. Deciding Which to Use
    4. 5. Looping with for, While, and Do...While!
      1. The for Loop
      2. Some for Loop Examples
      3. The Other Loops
    5. 6. Commenting Your Code...FTW!
      1. What Are Comments?
      2. Commenting Best Practices
    6. 7. Timers
      1. Delaying with setTimeout
    7. 8. Variable Scope
      1. Global Scope
      2. Local Scope
      3. Miscellaneous Scoping Shenanigans
    8. 9. Closures
      1. Functions within Functions
      2. When the Inner Functions Aren’t Self-Contained
    9. 10. Where Should Your Code Live?
      1. Approach #1: All the Code Lives in Your HTML Document
      2. Approach #2: The Code Lives in a Separate File
      3. So...Which Approach to Use?
  15. Part II: It’s an Object-Oriented World
    1. 11. Console Logging Basics
      1. Meet the Console
      2. Displaying the Console
      3. If You Want to Follow Along
      4. Console Logging 101
    2. 12. Of Pizza, Types, Primitives, and Objects
      1. Let’s First Talk About Pizza
      2. From Pizza to JavaScript!
      3. What Are Objects?
      4. The Predefined Objects Roaming Around in JavaScript
    3. 13. Arrays
      1. Creating an Array
      2. Accessing Array Values
      3. Adding Items to Your Array
      4. Removing Items from the Array
      5. Finding Items in the Array
      6. Merging Arrays
      7. Mapping, Filtering, and Reducing Arrays
      8. The Old School Way
      9. Modifying Each Array Item with Map
      10. Getting One Value from an Array of Items
      11. A Short Foray into Functional Programming
    4. 14. Strings
      1. The Basics
      2. String Properties and Methods
    5. 15. When Primitives Behave Like Objects
      1. Strings Aren’t the Only Problem
      2. Let’s Pick on Strings Anyway
      3. Why This Matters
    6. 16. Numbers
      1. Using a Number
      2. Operators
      3. Incrementing and Decrementing
      4. Hexadecimal and Octal Values
      5. Special Values—Infinity and NaN
      6. The Math Object
      7. Random Numbers
    7. 17. Getters and Setters
      1. A Tale of Two Properties
      2. Meet Getters and Setters
    8. 18. A Deeper Look at Objects
      1. Meet the Object
      2. Creating Custom Objects
      3. The this Keyword
    9. 19. Extending Built-In Objects
      1. Say Hello to prototype...again—Sort of!
      2. Extending Built-in Objects is Controversial
    10. 20. Using Classes
      1. The Class Syntax and Object Creation
      2. Extending Objects
    11. 21. Booleans and the Stricter === and !== Operators
      1. The Boolean Object
      2. The Boolean Function
      3. Strict Equality and Inequality Operators
    12. 22. Null and Undefined
      1. Null
      2. Undefined
  16. Part III: Working with the DOM
    1. 23. All About JSON (aka JavaScript Object Notation)
      1. What Is JSON?
      2. Looking Inside a JSON Object
      3. Reading JSON Data
      4. Writing JSON Data?
    2. 24. JS, the Browser, and the DOM
      1. What HTML, CSS, and JavaScript Do
      2. HTML Defines the Structure
      3. Prettify My World, CSS!
      4. It’s JavaScript Time!
      5. Meet the Document Object Model
    3. 25. Finding Elements in the DOM
      1. Meet the querySelector Family
      2. It Really Is the CSS Selector Syntax
    4. 26. Modifying DOM Elements
      1. DOM Elements Are Objects—Sort of!
      2. Let’s Actually Modify DOM Elements
    5. 27. Styling our Content
      1. Why Would We Set Styles Using JavaScript?
      2. A Tale of Two Styling Approaches
      3. Checking Whether a Class Value Exists
    6. 28. Traversing the DOM
      1. Finding Your Way Around
      2. Putting It All Together
    7. 29. Creating and Removing DOM Elements
      1. Creating Elements
      2. Removing Elements
      3. Cloning Elements
    8. 30. In-Browser Developer Tools
      1. Meet the Developer Tools
  17. Part IV: Dealing with Events
    1. 31. Events
      1. What Are Events?
      2. Events and JavaScript
      3. A Simple Example
      4. The Event Arguments and the Event Type
    2. 32. Event Bubbling and Capturing
      1. Event Goes Down. Event Goes Up.
      2. Meet the Phases
      3. Who Cares?
      4. Event, Interrupted
    3. 33. Mouse Events
      1. Meet the Mouse Events
      2. The MouseEvent Properties
      3. Dealing with the Mouse Wheel
    4. 34. Keyboard Events
      1. Meet the Keyboard Events
      2. Using These Events
      3. The Keyboard Event Properties
      4. Some Examples
    5. 35. Page Load Events and Other Stuff
      1. The Things That Happen During Page Load
      2. The DOMContentLoaded and load Events
      3. Scripts and Their Location in the DOM
      4. Script Elements—Async and Defer
    6. 36. Handling Events for Multiple Elements
      1. How to Do All of This
    7. 37. Conclusion
  18. Glossary
  19. Index
  20. Code Snippets
54.158.248.39