📲 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

real-style JavaScript questions asked by companies like Google, Amazon, Microsoft

Real Company-Level JavaScript Questions


1️⃣ (Amazon) – Closure + Loop Trap

for (var i = 0; i < 5; i++) {
setTimeout(() => console.log(i), i * 1000);
}

❓ Output:

5 5 5 5 5

💡 Why?

var is function-scoped → same i shared

✅ Fix:

for (let i = 0; i < 5; i++) {
setTimeout(() => console.log(i), i * 1000);
}

2️⃣ (Google) – Event Loop Priority

console.log("A");setTimeout(() => console.log("B"), 0);Promise.resolve().then(() => console.log("C"));console.log("D");

❓ Output:

A
D
C
B

💡 Why?

Microtasks (Promise) run before macrotasks (setTimeout)


3️⃣ (Amazon) – this Binding

const user = {
name: "Aditya",
greet() {
return function () {
console.log(this.name);
};
}
};user.greet()();

❓ Output:

undefined

💡 Why?

Returned function is called independently → this lost

✅ Fix:

return () => console.log(this.name);

4️⃣ (Google) – Hoisting Edge Case

console.log(foo());function foo() {
return "Hello";
}var foo = 10;

❓ Output:

Hello

💡 Why?

Function declaration takes priority over variable


5️⃣ (Microsoft) – Object Key Trick

const obj = {};obj[{}] = "A";
obj[{}] = "B";console.log(obj);

❓ Output:

{ "[object Object]": "B" }

💡 Why?

Objects used as keys are converted to string


6️⃣ (Amazon) – Async/Await Trick

async function test() {
console.log(1);
await Promise.resolve();
console.log(2);
}console.log(3);
test();
console.log(4);

❓ Output:

3
1
4
2

💡 Why?

await pauses → rest runs in microtask queue


7️⃣ (Google) – Prototype Behavior

function Person(name) {
this.name = name;
}Person.prototype.sayHi = function () {
return "Hi " + this.name;
};const p1 = new Person("A");
const p2 = new Person("B");p1.sayHi = function () {
return "Hello";
};console.log(p1.sayHi());
console.log(p2.sayHi());

❓ Output:

Hello
Hi B

💡 Why?

Method override only affects p1


8️⃣ (Amazon) – Chained Promises

Promise.resolve(1)
.then(x => x + 1)
.then(x => { throw new Error("Error"); })
.then(x => console.log(x))
.catch(() => 100)
.then(x => console.log(x));

❓ Output:

100

💡 Why?

Error goes to .catch(), then continues chain


9️⃣ (Google) – typeof Weirdness

console.log(typeof typeof 1);

❓ Output:

string

💡 Why?

typeof 1 → “number” (string), then typeof → string


🔟 (Amazon) – Array Mutation

const arr = [1, 2, 3];arr[10] = 99;console.log(arr.length);

❓ Output:

11

💡 Why?

Array becomes sparse


1️⃣1️⃣ (Google) – Equality Trap

console.log([] == ![]);

❓ Output:

true

💡 Why?

  • ![] → false
  • [] == false → true (coercion)

1️⃣2️⃣ (Amazon) – Function Currying

function add(a) {
return function (b) {
return function (c) {
return a + b + c;
};
};
}console.log(add(1)(2)(3));

❓ Output:

6

1️⃣3️⃣ (Google) – delete Operator

const obj = { name: "Aditya" };delete obj.name;
console.log(obj.name);

❓ Output:

undefined

1️⃣4️⃣ (Amazon) – Floating Precision

console.log(0.1 + 0.2 === 0.3);

❓ Output:

false

💡 Why?

Floating-point precision issue


1️⃣5️⃣ (Google) – setTimeout Order

for (let i = 1; i <= 3; i++) {
setTimeout(() => console.log(i), 0);
}console.log("Done");

❓ Output:

Done
1
2
3

🚀 What Companies Check

They are testing:

  • Deep understanding (not memorization)
  • Event loop mastery
  • Closures & scope
  • this behavior
  • Async handling

🎯 Pro Tip

In interviews:

  1. First predict output
  2. Then explain step-by-step
  3. Then suggest fix/improvement


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