chapter one

1 When a hello isn’t hello

 

This chapter covers

  • Exploring JavaScript runtime implementations
  • Comparing code execution across environments
  • Distinguishing between language, implementation, and host behaviors

JavaScript is a remarkably easy language to get started with. You can open a browser console and start coding immediately. There is no visible compilation step, no required type declarations, no manual memory management. A few lines of code and you can be off and running with a working application. This accessibility is both the language’s greatest strength and its most deceptive quality.

The language, and its implementations, hide their complexity almost too well. You can build your entire application without ever knowing that your runtime is secretly juggling multiple task queues, or that your numbers aren’t really numbers, or that you’re using promises in entirely the wrong way and that your code is running orders of magnitude slower than it otherwise could be as a result. Everything always seems fine right up until it isn’t or can even be completely correct in one environment while failing horribly in the next.

The ultimate goal of this book is to help the reader better understand, at a deep internal level, how the JavaScript primitives and tools they use every day fundamentally operate. It digs into the hidden complexity and examines what actually happens when your code runs, picking our way through the internal details that usually only matter when something goes wrong.

1.1 Setting the stage

1.2 But why?

1.3 Getting started

1.3.1 Scheduling?

1.3.2 Tasks and queues

1.3.3 Language, implementation, and host defined behavior

1.4 What you’ll need

1.5 Summary