Skip to content

(feat) Day 08 #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ I am an independent educator and open-source enthusiast who creates meaningful p
- **`Day 05: Mastering Loops and Iterations with Quizzes`** - [Watch Video](https://youtu.be/MDR43-2GvtA) || [Source Code](https://github.com/tapascript/40-days-of-javascript/blob/main/day-05/README.md)
- **`Day 06: Mastering Functions and its Use Cases with Quizzes`** - [Watch Video](https://youtu.be/6UJ9SyHvkJY) || [Source Code](https://github.com/tapascript/40-days-of-javascript/blob/main/day-06/README.md)
- **`Day 07: Building Beginner-Friendly JavaScript Projects`** - [Watch Video](https://youtu.be/fydbEttef04) || [Source Code](https://github.com/tapascript/40-days-of-javascript/blob/main/day-07/README.md)

### Module 2
- **`Day 08: Mastering JavaScript Execution Context Visually`** - [Watch Video](https://youtu.be/ylx5F7hbzVQ) || [Source Code](https://github.com/tapascript/40-days-of-javascript/blob/main/day-08/README.md)
33 changes: 33 additions & 0 deletions day-08/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Day 08 - 40 Days of JavaScript

## **🎯 Goal of This Lesson**

- ✅ Welcome to Module 2
- ✅ Why Execution Context
- ✅ Lexical Environment
- ✅ Execution Context
- ✅ Global Execution Context
- ✅ Function Execution Context
- ✅ GEC and FEC With Complex Examples
- ✅ Memory Management With Call Stack and Heap
- ✅ Task for YOU!

## 🫶 Support
Your support means a lot.

- Please SUBSCRIBE to [tapaScript YouTube Channel](https://youtube.com/tapasadhikary) if not done already. A Big Thank You!
- Liked my work? It takes months of hard work to create quality content and present it to you. You can show your support to me with a STAR(⭐) to this repository.

> Many Thanks to all the `Stargazers` who have supported this project with stars(⭐)

### 🤝 Sponsor My Work
I am an independent educator and open-source enthusiast who creates meaningful projects to teach programming on my YouTube Channel. **You can support my work by [Sponsoring me on GitHub](https://github.com/sponsors/atapas) or [Buy Me a Cofee](https://buymeacoffee.com/tapasadhikary)**.

## Video
Here is the video for you to go through and learn:

[![day-08](./banner.png)](https://youtu.be/ylx5F7hbzVQ "Video")

## **👩‍💻 🧑‍💻 Assignment Tasks**

Please find the task assignments in the [Task File](./task.md).
Binary file added day-08/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions day-08/call-stack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
console.log("Inside Global Execution Context");
var a = 5;
function testMe() {
console.log("Inside testMe Execution context");
var b = 10;
var user = {
name: "tapas",
country: "India"
}
function testAgain() {
console.log("Inside testAgain Execution Context");
console.log("Exiting testAgain Execution Context");
}
testAgain();
console.log("Exiting testMe execution context");
}
testMe();
console.log("Exiting global execution context");
8 changes: 8 additions & 0 deletions day-08/fec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var name = 'Tom';

function tom() {
console.log(this.name + ' Runs');
}

// Invoke the function tom()
tom();
5 changes: 5 additions & 0 deletions day-08/gec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var name = 'Tom';

function sayName() {
console.log(this.name);
}
12 changes: 12 additions & 0 deletions day-08/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="./index.js"></script>
</head>
<body>

</body>
</html>
5 changes: 5 additions & 0 deletions day-08/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var name = 'Tom';

function sayName() {
console.log(this.name);
}
16 changes: 16 additions & 0 deletions day-08/say-name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// More Code here
// ...
// ..
// .

fucntion sayName() {
var name = "someName";
console.log("The name is, ", name)
}

sayName();

// More Code here
// ...
// ..
// .
35 changes: 35 additions & 0 deletions day-08/task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Tasks
Please complete the following tasks and post them on the tapaScript Discord under "40 Days of JavaScript".

> **DO NOT USE AI to FIND ANSWERS**. If you are stuck, let's discuss it on DISCORD and learn. Also, please note that none of the answers need you to create any UI. Just focus on the logic building and print the output on the browser console.

## 1. Draw the Execution Context Diagram of the follwoing code and share as explained below:

```js
const message = "I can do it";

fucntion sum(a, b) {
const result = a + b;
return result;
}

function mul(a, b) {
const result = a * b;
return result;
}
function calc(a, b) {
return (sum(a, b) + mul(a,b))/2;
}

function getResult(a, b) {
return calc(a, b);
}

getResult(8, 5);
```

- Create the GEC and FEC with CP and EP flow
- Create the Stack and Heap Flow
- Create the Stack Diagram
- Create a Readme file with all the above diagram and share on Discord.