Member-only story

Javascript Execution Context and Hoisting

Deepak Gupta
TDS Archive
Published in
7 min readAug 6, 2019

This article is for those who don’t know how JavaScript is executed.

Prerequisite: You should know

  1. Scopes in javascript
  2. This keyword in javascript
  3. Stack in computers

Before we start can you answer below?

Is Javascript an Interpreted or a compiled language?

Yes, Javascript (JS) is an interpreted language, still has its own form of a compiler, run in what’s known as the Javascript engine.

Every web browser has its own form of a JavaScript engine Eg. Chrome has v8 and Mozilla has spider monkey etc, though they all have the same purpose. JavaScript engines simply convert JavaScript source code into a language the compiler can understand, then executes it.

Let’s start then,

Execution Context

An environment in which the javascript code runs is what form an execution context.

The execution context decides what particular piece of code has access to variables, functions, objects, etc.

If you have read the scope article then you should know what’s the global scope and local scope(function scope).

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Deepak Gupta
Deepak Gupta

Written by Deepak Gupta

COO @Steer Protocol| Write about Blockchain & Javascript | Take it easy

Responses (3)

What are your thoughts?

In your func1ExecutionObj during execution phase, `this`could be the global object or undefined. Can you please explain why could `this` be undefined here? Do you mean when the function is a function decalration and hasn't been called yet?

1

Notwe that the term Variable Object is not on the current specification and the term from ES5 onward is environment records

“compiler” can understand or “interpreter” can understand?