JavaScript Quiz: this, call, apply & bind

This JavaScript quiz covers this, one of the most asked interview topics. You will work out what this is in methods, detached functions and arrow functions, and set it yourself with call, apply and bind.

कठिन 10 सवाल ~8 मिनट पास होने के लिए 80% Node.js 22

मोड चुनें

आप गेस्ट के तौर पर खेल रहे हैं: XP और streak सेव रखने के लिए साइन इन करें।

सैंपल सवाल

सवाल 1 / 10

What does this print?

const user = {
  name: "Ann",
  greet() {
    return `Hi, ${this.name}`;
  },
};
console.log(user.greet());
जवाब दिखाएं

A. Hi, Ann When a function is called as user.greet(), this is the object before the dot. So this.name is "Ann".

इस क्विज़ में क्या है

  • this is decided by how a function is called, not where it is written
  • Losing this when a method is passed around
  • Arrow functions take this from the surrounding code
  • call and apply run a function with a chosen this
  • bind returns a new function with this fixed for good

अक्सर पूछे जाने वाले सवाल

क्या अकाउंट ज़रूरी है?

नहीं। कोई भी खेल सकता है। XP, streak, badge और हिस्ट्री सेव रखने के लिए साइन इन करें।

क्या मैं इसे दोबारा दे सकता हूं?

हां। आपका बेस्ट स्कोर सेव रहता है, और हर बार सवाल और जवाब शफ़ल होते हैं।