Skip to content

(feat) Day 09 #11

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 6, 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: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ I am an independent educator and open-source enthusiast who creates meaningful p
- **`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)
- **`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)
- **`Day 09: Mastering Temporal Dead Zone and Hoisting`** - [Watch Video](https://youtu.be/OqMxh1QdYEg) || [Source Code](https://github.com/tapascript/40-days-of-javascript/blob/main/day-09/README.md)
33 changes: 33 additions & 0 deletions day-09/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Day 09 - 40 Days of JavaScript

## **🎯 Goal of This Lesson**

- ✅ Welcome to Module 2
- ✅ Intro
- ✅ Misconception About Hoisting
- ✅ Variable Hoisting
- ✅ Hoisting and let and const
- ✅ Temporal Dead Zone(TDZ)
- ✅ Functional Hoisting
- ✅ Hoisting and Function As an Expression
- ✅ Task and What’s Next?

## 🫶 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-09](./banner.png)](https://youtu.be/OqMxh1QdYEg "Video")

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

Please find the task assignments in the [Task File](./task.md).
Binary file added day-09/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions day-09/feh.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test();

var test = function() {
console.log('I am being tested');
}
14 changes: 14 additions & 0 deletions day-09/fh.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Invoke a function, chase()
chase();

// Declare a function, chase()
function chase() {
console.log('Tom chases Jerry!');
// Invoke a function, caught();
caught();
}

// Declare a function, caught()
function caught() {
console.log('Tom caught Jerry :(')
}
12 changes: 12 additions & 0 deletions day-09/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>Hoisting</title>
<script defer src="./feh.js"></script>
</head>
<body>
<h1>Welcome to the <u>Day 09</u> of "40 Days of JavaScript!"</h1>
</body>
</html>
9 changes: 9 additions & 0 deletions day-09/task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 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. Expian Temporal Dead Zone by creating 3 variables in side a block. Post the code as your answer.

## 2. Explain Variable and Function Hoisting with Example. Post the code as your answer.

44 changes: 44 additions & 0 deletions day-09/vh.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// With var
{
console.log('name is ', name);
var name = "tom";
name = 'tom';
console.log('name is ', name);
}

// With let
{
console.log('name is ', name);
let name = "tom";
name = 'tom';
console.log('name is ', name);
}

// With const
{
console.log('name is ', name);
const name = "tom";
//name = 'tom';
console.log('name is ', name);
}


// Temporal Dead Zone(TDZ)

// TDZ = an area where you can not access a variable until it is initialized

// ReferenceError

{
// === name variable's TDZ started here
//
//console.log(name); // RerenceError
//
console.log(address); // RerenceError
let address = "bangalore";
//
let name = "tapaScript" // === name variable's TDZ ends here
console.log(name);
//
//
}