JavaScript Crash Course

Book description

JavaScript is the programming language of the internet—the secret sauce that makes websites dynamic, responsive, and all-around awesome. This fast-paced tutorial quickly teaches total beginners how to code in this popular, easy-to-learn language. Light-hearted and hands-on, the book introduces you to programming essentials through fun examples, hands-on exercises, and cool projects like building a Pong-style computer game. You’ll discover all of the important aspects of the language (without delving into expert-level nitty-gritty details or confusing jargon) as you develop a fast knack for programming with JavaScript.

  • Learn fundamental JS coding concepts, including objects, functions, arrays, and loops
  • Explore key web programming topics, like interactivity and drawing graphics with Canva
  • Use JavaScript to make games, apps, and even create music

Table of contents

  1. Praise for Javascript Crash Course
  2. Title Page
  3. Copyright
  4. Dedication
  5. About the Author and Technical Reviewer
  6. Acknowledgments
  7. Introduction
    1. Who Is This Book For?
    2. Why JavaScript?
    3. What Can You Expect to Learn?
    4. Online Resources
  8. Part I: The Language
    1. 1. Getting Started
      1. Using the JavaScript Console
      2. Using a Text Editor
      3. Summary
    2. 2. The Basics
      1. Expressions and Statements
      2. Numbers and Operators
        1. Order of Operations
        2. Floating Point
      3. Bindings
        1. Variables
        2. Constants
        3. Naming Conventions
      4. Incrementing and Decrementing
        1. Addition and Subtraction Assignment
        2. Multiplication and Division Assignment
      5. Strings
        1. Joining Strings
        2. Finding the Length of a String
        3. Getting a Character from a String
        4. Getting Multiple Characters from a String
        5. Trimming Whitespace from a String
        6. Other Useful String Methods
      6. Escape Sequences
      7. Template Literals
      8. Undefined and Null
      9. Booleans
        1. Logical Operators
        2. Comparison Operators
      10. Type Coercion
        1. Equality with Coercion
        2. Truthiness
        3. Uses for Truthiness
      11. Summary
    3. 3. Compound Data Types
      1. Arrays
        1. Creation and Indexing
        2. Arrays of Arrays
        3. Array Methods
      2. Objects
        1. Creating Objects
        2. Accessing Object Values
        3. Setting Object Values
        4. Working with Objects
      3. Nesting Objects and Arrays
        1. Nesting with Literals
        2. Nesting with Variables
        3. Exploring Nested Objects in the Console
        4. Printing Nested Objects with JSON.stringify
      4. Summary
    4. 4. Conditionals and Loops
      1. Making Decisions with Conditionals
        1. if Statements
        2. if…else Statements
        3. More Complex Conditions
        4. Chained if…else Statements
      2. Repeating Code with Loops
        1. while Loops
        2. for Loops
        3. for…of Loops
        4. for…in Loops
      3. Summary
    5. 5. Functions
      1. Declaring and Calling Functions
        1. Return Values
        2. Parameter Types
        3. Side Effects
      2. Passing a Function as an Argument
      3. Other Function Syntaxes
        1. Function Expressions
        2. Arrow Functions
      4. Rest Parameters
      5. Higher-Order Functions
        1. Array Methods That Take Callbacks
        2. Custom Functions That Take Callbacks
        3. Functions That Return Functions
      6. Summary
    6. 6. Classes
      1. Creating Classes and Instances
      2. Inheritance
      3. Prototype-Based Inheritance
        1. Using Constructors and Prototypes
        2. Comparing Constructors and Classes
        3. Exploring Object.prototype
        4. Walking the Prototype Chain
        5. Overriding a Method
      4. Summary
  9. Part II: Interactive Javascript
    1. 7. HTML, the DOM, and CSS
      1. HTML
        1. Creating an HTML Document
        2. Understanding Nested Relationships
      2. The Document Object Model
        1. The DOM API
        2. Element Identifiers
      3. script Elements
      4. CSS
        1. link Elements
        2. Rulesets
        3. Selectors
      5. Using CSS Selectors in JavaScript
      6. Summary
    2. 8. Event-based Programming
      1. Event Handlers
        1. Event Bubbling
        2. Event Delegation
      2. Mouse Movement Events
      3. Keyboard Events
      4. Summary
    3. 9. The Canvas Element
      1. Creating a Canvas
      2. Making Static Drawings
        1. Drawing Outlined Rectangles
        2. Drawing Other Shapes Using Paths
      3. Interacting with the Canvas
      4. Animating the Canvas
      5. Summary
  10. Part III: Projects
    1. Project 1: Creating a Game
      1. 10. Pong
        1. The Game
        2. Setup
        3. The Ball
        4. Refactoring
        5. The Game Loop
        6. Bouncing
        7. The Paddles
          1. Moving the Paddles with Player Input
          2. Detecting Paddle Collisions
          3. Bouncing Near the Paddle Ends
        8. Scoring Points
        9. Computer Control
        10. Game Over
        11. The Complete Code
        12. Summary
      2. 11. Object-Oriented Pong
        1. Object-Oriented Design
        2. The File Structure
        3. The GameView Class
        4. The Game Elements
          1. The Paddles
          2. The Ball
        5. The Scores and Computer Classes
        6. The Game Class
        7. Starting the Game
        8. Summary
    2. Project 2: Making Music
      1. 12. Generating Sounds
        1. The Web Audio API
          1. Setting Up
          2. Generating a Tone with the Web Audio API
        2. The Tone.js Library
          1. Generating a Tone with Tone.js
          2. Understanding the Tone.Synth Options
          3. Playing More Notes in Sequence
          4. Playing Multiple Notes at Once
        3. The Tone.js Transport
          1. Tone.Loop
          2. Tone.Sequence
          3. Tone.Part
        4. Making Drum Sounds
          1. Hi-Hat Synthesis
          2. Snare Synthesis
          3. Kick Synthesis
          4. Reverb
          5. A Drum Loop
        5. Working with Samples
        6. Summary
      2. 13. Writing a Song
        1. Getting Organized
        2. Event Handling
        3. Making the Drumbeat
        4. Adding the Bass Lines
        5. Adding Chords
        6. Playing a Tune
        7. The Complete Code
        8. Summary
    3. Project 3: Visualizing Data
      1. 14. Introducing the D3 Library
        1. The SVG Graphics Format
          1. Grouping Elements
          2. Drawing Circles
          3. Defining Paths
          4. Styling Elements with CSS
          5. Adding Interactivity with JavaScript
        2. The D3 Library
          1. Setup
          2. Selections
          3. Data Binding
          4. Data Joins
          5. Real-Time Updates
          6. Transitions and Key Functions
          7. Advanced Joins
        3. Creating a Bar Graph
          1. Setting Up
          2. Calculating Character Frequencies
          3. Drawing the Bar Graph
          4. Styling with CSS and Regular Expressions
          5. Cleaning the Data
          6. Animating the Changes
        4. Summary
      2. 15. Visualizing Data from the Github Search API
        1. Setting Up
        2. Fetching Data
        3. The Basic Visualization
          1. Creating the Elements
          2. Drawing the Axes
          3. Drawing the Bars
        4. Improving the Visualization
          1. Showing Repository Info
          2. Color-Coding the Bars
          3. Labeling the Left Axis
        5. Adding Interactivity
          1. Filtering the Data by License
          2. Animating the Changes
        6. The Complete Code
        7. Summary
  11. Afterword
  12. Index

Product information

  • Title: JavaScript Crash Course
  • Author(s): Nick Morgan
  • Release date: March 2024
  • Publisher(s): No Starch Press
  • ISBN: 9781718502260