How JavaScript Works—Execution Context

Learn how JavaScript code is executed internally using the execution context.

Introduction

In this lesson, we will learn about how JavaScript works and how JavaScript code is executed behind the scenes. We will also answer two questions:

  • Is JavaScript a synchronous or an asynchronous language?

  • Is JavaScript a single-threaded or a multi-threaded programming language?

Execution context

Everything in JavaScript happens inside an execution context. You can think of this execution context as a big container in which the whole JavaScript code is executed. An execution context consists of two components: the variable environment and the thread of execution.

Below is a simple illustration to help you understand the design of the execution context.

Get hands-on with 1200+ tech skills courses.