📲 Download Utility Tools Apps

EMI Calculator

Download EMI Calculator

SOA Games

Download SOA Games

SOA Technology App

Download SOA Technology

BMI Checker

Download BMI Checker

Task Jira

Download Task Jira

Laughing Adda

Download Laughing Adda

📅 हिंदी कैलेंडर ऐप डाउनलोड करें

Download Shubhcalendar App

9️⃣ Advanced JavaScript

1️⃣ Scope

Scope defines where variables are accessible in your code.

Types:

  • Global Scope → accessible everywhere
  • Function Scope → inside a function
  • Block Scope → inside {} (let, const)
let a = 10; // globalfunction test() {
let b = 20; // function scope
if (true) {
let c = 30; // block scope
}
}

👉 c is NOT accessible outside block.


2️⃣ Hoisting

Hoisting means variables and functions are moved to the top of their scope during execution.

console.log(a); // undefined
var a = 5;

Internally becomes:

var a;
console.log(a);
a = 5;

⚠️ Important:

  • var → hoisted with undefined
  • let/const → hoisted but in temporal dead zone

3️⃣ Closures

Closure = function + its lexical environment

A function remembers variables from its outer scope.

function outer() {
let count = 0; return function inner() {
count++;
console.log(count);
};
}let fn = outer();
fn(); // 1
fn(); // 2

👉 inner() remembers count even after outer() is finished.


4️⃣ Execution Context

When JS runs code, it creates an execution context.

Types:

  • Global Execution Context (GEC)
  • Function Execution Context (FEC)

Phases:

  1. Memory Creation Phase
  2. Execution Phase
var x = 10;function test() {
var y = 20;
}

👉 JS first allocates memory, then executes line by line.


5️⃣ Call Stack

Call Stack = how JavaScript manages function calls

function a() {
b();
}
function b() {
console.log("Hello");
}
a();

Stack flow:

a()
b()
console.log()

👉 Last In → First Out (LIFO)


6️⃣ this Keyword

this refers to the object that is calling the function

Examples:

let obj = {
name: "Aditya",
greet: function () {
console.log(this.name);
}
};obj.greet(); // Aditya

Rules:

  • In object → refers to object
  • In function → window (or undefined in strict mode)
  • In arrow function → inherits from parent

7️⃣ Prototype

Every JavaScript object has a prototype, which is another object.

function Person(name) {
this.name = name;
}Person.prototype.sayHello = function () {
console.log("Hello " + this.name);
};let p1 = new Person("Aditya");
p1.sayHello();

👉 sayHello is shared among all objects (memory efficient)


8️⃣ Prototypal Inheritance

Objects can inherit properties from another object

let parent = {
greet() {
console.log("Hello");
}
};let child = Object.create(parent);child.greet(); // Hello

👉 child inherits from parent


🧠 Quick Summary

ConceptMeaning
ScopeWhere variables are accessible
HoistingVariables/functions moved to top
ClosuresFunction remembers outer variables
Execution ContextEnvironment where code runs
Call StackTracks function calls
thisRefers to calling object
PrototypeShared object properties
InheritanceOne object uses another’s properties


AI Spiritual Tools & Interactive Experiences

Explore powerful AI-driven tools for daily guidance, spirituality, fun quizzes, and self-discovery.

Today’s Quote

Get inspiring daily quotes powered by AI to motivate and guide your day.

Explore Now

AI Tarot Card Reader

Reveal insights about your future, love, and career with AI tarot readings.

Read Tarot

Love Match Calculator

Check compatibility and love predictions using AI-based analysis.

Check Match

Fortune Cookie

Open an AI fortune cookie and receive wisdom, luck, and fun messages.

Open Cookie

Quiz Categories

Engage with knowledge-based and fun quizzes across multiple categories.

Start Quiz

Panchang Calendar

View daily Panchang, auspicious timings, tithi, nakshatra, and festivals.

View Panchang

Online Numerology

Discover your destiny number, life path, and numerology predictions.

Calculate Now

Spiritual Feeds

Stay connected with spiritual thoughts, mantras, and divine content.

View Feeds

Quiz Hub

Attempt trending quizzes on GK, spirituality, festivals, and more.

Explore Quizzes