Books & Videos

Table of Contents

  1. Chapter 1 Getting your feet wet

    1. The way JavaScript works

    2. How you’re going to write JavaScript

    3. How to get JavaScript into your page

    4. JavaScript, you’ve come a long way baby...

    5. How to make a statement

    6. Variables and values

    7. Back away from that keyboard!

    8. Express yourself

    9. Doing things more than once

    10. How the while loop works

    11. Making decisions with JavaScript

    12. And, when you need to make LOTS of decisions

    13. Reach out and communicate with your user

    14. A closer look at console.log

    15. Opening the console

    16. Coding a Serious JavaScript Application

    17. How do I add code to my page? (let me count the ways)

    18. We’re going to have to separate you two

  2. Chapter 2 Going further

    1. Let’s build a Battleship game

    2. Our first attempt...

    3. First, a high-level design

    4. A few more details...

    5. Working through the Pseudocode

    6. Oh, before we go any further, don’t forget the HTML!

    7. Writing the Simple Battleship code

    8. Now let’s write the game logic

    9. Step One: setting up the loop, getting some input

    10. How prompt works

    11. Checking the user’s guess

    12. So, do we have a hit?

    13. Adding the hit detection code

    14. Hey, you sank my battleship!

    15. Provide some post-game analysis

    16. And that completes the logic!

    17. Doing a little Quality Assurance

    18. Can we talk about your verbosity...

    19. Finishing the Simple Battleship game

    20. How to assign random locations

    21. The world-famous recipe for generating a random number

    22. Back to do a little more QA

    23. Congrats on your first true JavaScript program, and a short word about reusing code

  3. Chapter 3 Getting functional

    1. What’s wrong with the code anyway?

    2. By the way, did we happen to mention FUNCTIONS?

    3. Okay, but how does it actually work?

    4. What can you pass to a function?

    5. JavaScript is pass-by-value.

    6. Weird Functions

    7. Functions can return things too

    8. Tracing through a function with a return statement

    9. Global and local variables

    10. Knowing the scope of your local and global variables

    11. The short lives of variables

    12. Don’t forget to declare your locals!

  4. Chapter 4 Arrays

    1. Can you help Bubbles-R-Us?

    2. How to represent multiple values in JavaScript

    3. How arrays work

    4. How to access an array item

    5. Updating a value in the array

    6. How big is that array anyway?

    7. The Phrase-O-Matic

    8. Meanwhile, back at Bubbles-R-Us...

    9. How to iterate over an array

    10. But wait, there’s a better way to iterate over an array

    11. It’s that time again.... Can we talk about your verbosity?

    12. Redoing the for loop with the post-increment operator

    13. Quick test drive

    14. Creating an array from scratch (and adding to it)

    15. And the winners are...

    16. A quick survey of the code...

    17. Writing the printAndGetHighScore function

    18. Refactoring the code using printAndGetHighScore

    19. Putting it all together...

  5. Chapter 5 A trip to Objectville

    1. Did someone say “Objects”?!

    2. Thinking about properties...

    3. How to create an object

    4. What is Object-Oriented Anyway?

    5. How properties work

    6. How does a variable hold an object? Inquiring minds want to know...

    7. Comparing primitives and objects

    8. Doing even more with objects...

    9. Stepping through pre-qualification

    10. Let’s talk a little more about passing objects to functions

    11. Oh Behave! Or, how to add behavior to your objects

    12. Improving the drive method

    13. Why doesn’t the drive method know about the started property?

    14. How this works

    15. How behavior affects state... Adding some Gas-o-line

    16. Now let’s affect the behavior with the state

    17. Congrats on your first objects!

    18. Guess what? There are objects all around you! (and they’ll make your life easier)

  6. Chapter 6 Getting to know the DOM

    1. In our last chapter, we left you with a little challenge. The “crack the code challenge.”

    2. So what does the code do?

    3. How JavaScript really interacts with your page

    4. How to bake your very own DOM

    5. A first taste of the DOM

    6. Getting an element with getElementById

    7. What, exactly, am I getting from the DOM?

    8. Finding your inner HTML

    9. What happens when you change the DOM

    10. A test drive around the planets

    11. Don’t even think about running my code until the page is fully loaded!

    12. You say “event handler,” I say “callback”

    13. How to set an attribute with setAttribute

    14. More fun with attributes! (you can GET attributes too)

    15. So what else is a DOM good for anyway?

  7. Chapter 7 Serious types

    1. The truth is out there...

    2. Watch out, you might bump into undefined when you aren’t expecting it...

    3. How to use null

    4. Dealing with NaN

    5. It gets even weirder

    6. We have a confession to make

    7. Understanding the equality operator (otherwise known as ==)

    8. How equality converts its operands (sounds more dangerous than it actually is)

    9. How to get strict with equality

    10. Even more type conversions...

    11. How to determine if two objects are equal

    12. The truthy is out there...

    13. What JavaScript considers falsey

    14. The Secret Life of Strings

    15. How a string can look like a primitive and an object

    16. A five-minute tour of string methods (and properties)

    17. Chair Wars (or How Really Knowing Types Can Change Your Life)

  8. Chapter 8 Building an app

    1. This time, let’s build a REAL Battleship game

    2. Stepping back... to HTML and CSS

    3. Creating the HTML page: the Big Picture

    4. Adding some more style

    5. Using the hit and miss classes

    6. How to design the game

    7. Implementing the View

    8. How displayMessage works

    9. How displayHit and displayMiss work

    10. The Model

    11. How we’re going to represent the ships

    12. Implementing the model object

    13. Setting up the fire method

    14. Implementing the Controller

    15. Processing the player’s guess

    16. Planning the code...

    17. Implementing parseGuess

    18. Counting guesses and firing the shot

    19. How to add an event handler to the Fire! button

    20. Passing the input to the controller

    21. How to place ships

    22. Writing the generateShip method

    23. Generate the starting location for the new ship

    24. Completing the generateShip method

  9. Chapter 9 Handling events

    1. What are events?

    2. What’s an event handler?

    3. How to create your first event handler

    4. Test drive your event

    5. Getting your head around events... by creating a game

    6. Implementing the game

    7. Test drive

    8. Let’s add some more images

    9. Now we need to assign the same event handler to each image’s onclick property

    10. How to reuse the same handler for all the images

    11. How the event object works

    12. Putting the event object to work

    13. Test drive the event object and target

    14. Events and queues

    15. Even more events

    16. How setTimeout works

    17. Finishing the image game

    18. Test driving the timer

  10. Chapter 10 Liberated functions

    1. The mysterious double life of the function keyword

    2. Function declarations versus function expressions

    3. Parsing the function declaration

    4. What’s next? The browser executes the code

    5. Moving on... The conditional

    6. How functions are values too

    7. Did we mention functions have First Class status in JavaScript?

    8. Flying First Class

    9. Writing code to process and check passengers

    10. Iterating through the passengers

    11. Passing a function to a function

    12. Returning functions from functions

    13. Writing the flight attendant drink order code

    14. The flight attendant drink order code: a different approach

    15. Taking orders with first class functions

    16. Webville Cola

    17. How the array sort method works

    18. Putting it all together

    19. Take sorting for a test drive

  11. Chapter 11 Serious functions

    1. Taking a look at the other side of functions...

    2. How to use an anonymous function

    3. We need to talk about your verbosity, again

    4. When is a function defined? It depends...

    5. What just happened? Why wasn’t fly defined?

    6. How to nest functions

    7. How nesting affects scope

    8. A little review of lexical scope

    9. Where things get interesting with lexical scope

    10. Functions Revisited

    11. Calling a function (revisited)

    12. What the heck is a closure?

    13. Closing a function

    14. Using closures to implement a magic counter

    15. Looking behind the curtain...

    16. Creating a closure by passing a function expression as an argument

    17. The closure contains the actual environment, not a copy

    18. Creating a closure with an event handler

    19. How the Click me! closure works

  12. Chapter 12 Creating objects

    1. Creating objects with object literals

    2. Using conventions for objects

    3. Introducing Object Constructors

    4. How to create a Constructor

    5. How to use a Constructor

    6. How constructors work

    7. You can put methods into constructors as well

    8. It’s Production Time!

    9. Let’s test drive some new cars

    10. Don’t count out object literals just yet

    11. Rewiring the arguments as an object literal

    12. Reworking the Car constructor

    13. Understanding Object Instances

    14. Even constructed objects can have their own independent properties

    15. Real World Constructors

    16. The Array object

    17. Even more fun with built-in objects

  13. Chapter 13 Extra strength objects

    1. Hey, before we get started, we’ve got a better way to diagram our objects

    2. Revisiting object constructors: we’re reusing code, but are we being efficient?

    3. Is duplicating methods really a problem?

    4. What are prototypes?

    5. Inheriting from a prototype

    6. How inheritance works

    7. Overriding the prototype

    8. How to set up the prototype

    9. Prototypes are dynamic

    10. A more interesting implementation of the sit method

    11. One more time: how the sitting property works

    12. How to approach the design of the show dogs

    13. Setting up a chain of prototypes

    14. How inheritance works in a prototype chain

    15. Creating the show dog prototype

    16. Creating a show dog instance

    17. A final cleanup of show dogs

    18. Stepping through

    19. The chain doesn’t end at dog

    20. Using inheritance to your advantage... by overriding built-in behavior

    21. Using inheritance to your advantage... by extending a built-in object

    22. Grand Unified Theory of

    23. Better living through objects

    24. Putting it all together

    25. What’s next?

  1. Appendix Leftovers: The top ten topics (we didn’t cover)

    1. #1 jQuery

    2. #2 Doing more with the DOM

    3. #3 The Window Object

    4. #4 Arguments

    5. #5 Handling exceptions

    6. #6 Adding event handlers with addEventListener

    7. #7 Regular Expressions

    8. #8 Recursion

    9. #9 JSON

    10. #10 Server-side JavaScript

  2. Colophon