Most important FAQ javascript questions asked so far in indian history list with solutions in Hindi

 JavaScript (JS) has become one of the most important programming languages in web development, and many competitive exams, interviews, and coding platforms in India have seen various JavaScript-related questions over the years. While I cannot provide a list of all JavaScript questions ever asked in Indian history, I can provide a collection of important JavaScript questions and answers that have been commonly asked in coding interviews, competitive programming, and technical interviews in India. The solutions are explained in Hindi to help developers in the Indian community.

1. What is JavaScript?

  • Answer (Hindi): JavaScript एक high-level programming language है, जिसे web development में primarily client-side scripting के लिए उपयोग किया जाता है। यह language dynamic है, और HTML और CSS के साथ मिलकर interactive web pages बनाने में मदद करती है। JavaScript का मुख्य उद्देश्य web pages को interactive बनाना है। इसके द्वारा आप form validation, event handling, animations, AJAX calls, आदि कर सकते हैं।

2. Explain the difference between null and undefined in JavaScript.

  • Answer (Hindi):
    • undefined: यह एक primitive value है, जो तब मिलता है जब कोई variable declare तो किया जाता है, लेकिन उसे कोई value assign नहीं की जाती है।
    • null: यह एक intentional assignment है, जो signify करता है कि variable की कोई value नहीं है। इसे explicitly किसी variable को खाली करने के लिए assign किया जाता है।
    • Example:
      let a; console.log(a); // undefined let b = null; console.log(b); // null

3. What are JavaScript data types?

  • Answer (Hindi): JavaScript में दो प्रकार के data types होते हैं:
    • Primitive Data Types: ये immutable होते हैं, जैसे:
      • String (जैसे: "Hello")
      • Number (जैसे: 25)
      • BigInt (जैसे: 123456789123456789n)
      • Boolean (जैसे: true, false)
      • undefined
      • null
      • Symbol
    • Non-Primitive Data Types:
      • Object (जैसे: {name: "John", age: 30})
      • Array (जैसे: [1, 2, 3])
      • Function (जैसे: function myFunction() {...})

4. What is a closure in JavaScript?

  • Answer (Hindi): Closure एक JavaScript function है जो outer function के variables को अपनी inner function में access करने की अनुमति देता है, भले ही outer function execution complete हो चुका हो। Closure का उपयोग state को retain करने और private variables को manage करने के लिए किया जाता है।
    • Example:
      function outer() { let count = 0; return function inner() { count++; console.log(count); }; } const increment = outer(); increment(); // 1 increment(); // 2

5. Explain Event Delegation in JavaScript.

  • Answer (Hindi): Event delegation वह technique है जहां हम parent element पर event listener attach करते हैं, ताकि child elements पर होने वाले events को handle किया जा सके। इससे event listeners की संख्या कम होती है और performance बेहतर होती है।
    • Example:
      document.querySelector('#parent').addEventListener('click', function(e) { if (e.target && e.target.matches('button.classname')) { console.log('Button clicked!'); } });

6. What is the difference between == and === in JavaScript?

  • Answer (Hindi):
    • == (Loose equality) दो values को compare करते समय type conversion करता है। इसका मतलब है कि अगर values अलग types की भी हों, तो JavaScript उन्हें बराबर मान सकता है।
    • === (Strict equality) दो values को compare करते समय type conversion नहीं करता है। यदि types different हैं तो ये false return करेगा।
    • Example:
      0 == '0'; // true 0 === '0'; // false

7. What is hoisting in JavaScript?

  • Answer (Hindi): Hoisting JavaScript की एक behavior है, जिसमें variable और function declarations को उनके scope के top पर ले जाया जाता है, लेकिन variable को undefined और function को उनका body normal तरीके से accessible बन जाता है।
    • Example:
      console.log(a); // undefined var a = 10; // Function hoisting hello(); // "Hello" function hello() { console.log("Hello"); }

8. What are Promises in JavaScript?

  • Answer (Hindi): Promise एक JavaScript object है जो asynchronous operation के completion को represent करता है। यह तीन states में हो सकता है:
    • Pending: Promise अभी resolved या rejected नहीं हुआ है।
    • Resolved: Promise सफलतापूर्वक complete हो गया है।
    • Rejected: Promise में error आई है।
    • Example:
      let promise = new Promise((resolve, reject) => { let success = true; if (success) { resolve("Success"); } else { reject("Error"); } }); promise.then(result => console.log(result)) .catch(error => console.log(error));

9. What is the use of bind, call, and apply methods in JavaScript?

  • Answer (Hindi):
    • bind(): यह method एक नए function को return करता है, जिसमें this context को bind किया जाता है।
    • call(): यह method function को तुरंत execute करता है और this को explicitly pass करता है।
    • apply(): यह method call() जैसा ही होता है, लेकिन arguments को array के रूप में pass करता है।
    • Example:
      const person = { name: "John" }; function greet(age, country) { console.log(this.name + " is " + age + " years old and lives in " + country); } greet.call(person, 30, "India"); // John is 30 years old and lives in India greet.apply(person, [30, "India"]); // John is 30 years old and lives in India const greetBind = greet.bind(person, 30, "India"); greetBind(); // John is 30 years old and lives in India

10. Explain the concept of this in JavaScript.

  • Answer (Hindi): this JavaScript में एक special keyword है जो function के context को reference करता है। यह हमेशा function के execution context (calling object) के आधार पर निर्धारित होता है।
    • Example:
      function show() { console.log(this); } const obj = { show: show }; obj.show(); // this will refer to obj

11. What is the difference between setTimeout and setInterval?

  • Answer (Hindi):
    • setTimeout: इसे एक बार के लिए delay के बाद execute करने के लिए use किया जाता है। यह केवल एक बार callback function execute करता है।
    • setInterval: इसे बार-बार execute करने के लिए use किया जाता है। यह function को हर interval के बाद repeat करता है।
    • Example:
      setTimeout(() => console.log("Executed once"), 1000); // Executes once after 1 second setInterval(() => console.log("Executed every 2 seconds"), 2000); // Executes every 2 seconds

Conclusion

यह केवल कुछ JavaScript से संबंधित महत्वपूर्ण सवाल थे जो Indian interviews और coding platforms में अक्सर पूछे जाते हैं। आपको इन सवालों को समझने और उन्हें implement करने में मदद मिलेगी। इन सवालों के अलावा, JavaScript की दुनिया में और भी बहुत सी advanced topics जैसे कि asynchronous programming, event loop, memory management, design patterns, ES6+ features, और web APIs हैं जिन्हें आपको सीखने की कोशिश करनी चाहिए।

Comments

Popular posts from this blog

PrimeNG tutorial with examples using frequently used classes

Docker and Kubernetes Tutorials and QnA

Building strong foundational knowledge in frontend development topics