TGViewer
Web Development - HTML, CSS & JavaScript Web Development - HTML, CSS & JavaScript @javascript_courses · 55.7K subscribers
Post #3605 2.36K
function test() {
    var age = 25;
    console.log(age);
}

age

cannot be accessed outside
test()

.

Block Scope
let

and
const

are block-scoped.
if (true) {
    let x = 10;
    const y = 20;
    console.log(x, y);
}

x

and
y

cannot be accessed outside the
if

block.

18. What is strict mode ("use strict")?

Strict mode enables a stricter set of JavaScript rules and helps catch certain programming mistakes.

Example:
"use strict";
x = 10;

This produces a
ReferenceError

because
x

was not declared. 

Without strict mode, older JavaScript behavior could create a global variable in some situations.

Benefits:

Catches common mistakes

Prevents accidental global variables

Makes some unsafe operations throw errors

Helps write cleaner code

19. What are comments in JavaScript?

Comments are text ignored by the JavaScript engine. They are used to explain code or temporarily disable code.

Single-Line Comment:
// This is a comment
console.log("Hello");

Multi-Line Comment:
/*
   This is a
   multi-line comment
*/
console.log("Hello");

Why Use Comments?

✅ Explain complex logic

✅ Improve code readability

✅ Help other developers understand the code

✅ Document important decisions

20. What are JavaScript modules?

Modules allow you to split JavaScript code into separate, reusable files.

They help organize large applications and prevent unnecessary global variables.

Export:
// math.js
export function add(a, b) {
    return a + b;
}

Import:
// app.js
import { add } from "./math.js";
console.log(add(10, 20));

Types of Exports:

Named exports

Default exports

Default Export:
export default function greet() {
    console.log("Hello");
}

Important Interview Point:

ES Modules use
import

and
export

. They are the standard module system for modern JavaScript.

❤️ Double Tap For Part 3
  • ❤ 11
More from @javascript_courses
  1. Oct 7, 2026🚀𝗣𝗮𝘆 𝗔𝗳𝘁𝗲𝗿 𝗣𝗹𝗮𝗰𝗲𝗺𝗲𝗻𝘁 𝗧𝗿𝗮𝗶𝗻𝗶𝗻𝗴 | 𝗕𝗲𝗰𝗼𝗺𝗲 𝗮 𝗙𝘂𝗹𝗹𝘀𝘁𝗮𝗰…
  2. Oct 7, 2026𝗠𝗮𝘀𝘁𝗲𝗿 𝗣𝗼𝘄𝗲𝗿 𝗕𝗜 𝗳𝗼𝗿 𝗙𝗥𝗘𝗘! 🔥 Learn Power BI through these FREE learnin…
  3. Oct 4, 2026DSA Handwritten Notes
  4. Sep 28, 2026To learn web design and development from basic to advanced levels, you can follow these st…
  5. Sep 27, 202610 Websites Every Developer & AI Enthusiast Should Bookmark ✅ roadmap.sh – Step-by-step le…
  6. Sep 26, 2026🔹 Escape Characters 2️⃣5️⃣ New Line You can use \n and \t: const message1 = "Hello\nWorld…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →