0% found this document useful (0 votes)
6 views8 pages

JavaScript Important QA

The document contains a series of important questions and answers regarding JavaScript, covering topics such as its features, data types, functions, scope, objects, arrays, the DOM, asynchronous programming, ES6+ features, advanced concepts, and error handling. Key differences between JavaScript and Java, as well as between various JavaScript constructs like var, let, and const, are highlighted. Additionally, it explains concepts like promises, async/await, and error handling mechanisms.

Uploaded by

112324407084
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views8 pages

JavaScript Important QA

The document contains a series of important questions and answers regarding JavaScript, covering topics such as its features, data types, functions, scope, objects, arrays, the DOM, asynchronous programming, ES6+ features, advanced concepts, and error handling. Key differences between JavaScript and Java, as well as between various JavaScript constructs like var, let, and const, are highlighted. Additionally, it explains concepts like promises, async/await, and error handling mechanisms.

Uploaded by

112324407084
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JavaScript Important Questions & Answers

1. Basics of JavaScript

Q1. What is JavaScript and its features?


Ans: JavaScript ek lightweight, interpreted scripting language hai jo mainly web pages ko
interactive banane ke liye use hoti hai. Yeh client-side aur server-side dono par chal sakti
hai. Important features: 1. Dynamic typing 2. Prototype-based object orientation 3.
Event-driven programming 4. Cross-platform support

Q2. Difference between JavaScript and Java?


Ans: Java ek pure object-oriented programming language hai, jabki JavaScript lightweight
scripting language hai. Java compile hoti hai aur JVM par run hoti hai, jabki JavaScript
browser ke JavaScript engine par directly execute hoti hai.

Q3. What are data types in JavaScript?


Ans: JavaScript ke major data types: 1. Primitive Types - String, Number, Boolean, Null,
Undefined, Symbol, BigInt 2. Non-Primitive Types - Objects, Arrays, Functions
2. Functions & Scope

Q4. Difference between var, let, and const?


Ans: var - Function scoped hoti hai aur hoisting hoti hai. let - Block scoped hoti hai,
hoisting hoti hai but initialization pe error deta hai. const - Block scoped hoti hai, value
change nahi hoti.

Q5. What is hoisting in JavaScript?


Ans: Hoisting ek mechanism hai jisme variables aur functions ke declarations
automatically top par move ho jaate hain execution se pehle.

Q6. What is closure in JavaScript?


Ans: Closure ek function ke andar dusra function hota hai jo outer function ke variables ko
access kar sakta hai even after outer function execution is complete.
3. Objects & Arrays

Q7. What are arrays and objects?


Ans: Array ek ordered collection of values hoti hai jabki object key-value pairs ka collection
hota hai.

Q8. Difference between deep copy and shallow copy?


Ans: Shallow copy sirf top-level elements copy karta hai aur nested objects ke references
same hote hain. Deep copy poora independent copy banata hai including nested
structures.
4. DOM (Document Object Model)

Q9. What is DOM?


Ans: DOM ek programming interface hai jo HTML aur XML documents ko tree structure
me represent karta hai aur JavaScript se manipulate karne ki facility deta hai.

Q10. Difference between innerHTML and textContent?


Ans: innerHTML HTML tags ke sath content return karta hai jabki textContent sirf plain text
return karta hai bina HTML tags ke.
5. Asynchronous JavaScript

Q11. What are promises in JavaScript?


Ans: Promise ek object hai jo asynchronous operation ke result ko represent karta hai.
Yeh teen states me ho sakta hai: Pending, Fulfilled, Rejected.

Q12. What is async/await?


Ans: async/await promise ko handle karne ka easy syntax hai jisse asynchronous code
synchronous style me likha ja sakta hai.
6. ES6+ Features

Q13. What are template literals?


Ans: Template literals backticks (`) ke andar likhe jate hain aur variable interpolation
(${variable}) allow karte hain.

Q14. Difference between forEach, map, and filter?


Ans: forEach sirf loop lagata hai aur kuch return nahi karta. map naya array return karta
hai. filter conditionally naya array return karta hai.
7. Advanced JavaScript Concepts

Q15. What is 'this' keyword in JavaScript?


Ans: 'this' current execution context ko represent karta hai. Browser me by default yeh
window object hota hai.

Q16. What is prototypal inheritance?


Ans: Prototypal inheritance me ek object dusre object ke properties aur methods ko inherit
kar sakta hai using prototype chain.
8. Error Handling

Q17. Explain try-catch-finally.


Ans: try block me code execute hota hai, agar error aata hai to catch block execute hota
hai. finally block hamesha run hota hai chahe error aaye ya nahi.

Q18. Difference between runtime error and syntax error?


Ans: Syntax error code compile hote waqt aata hai, runtime error code execute karte waqt
aata hai.

You might also like