❓ Question Answer

Chapter 14 - JavaScript Introduction

Q. What is JavaScript?
Ans. JavaScript is a programming language commonly used to add interactivity and dynamic behaviour to web pages.
Q. What are the main uses of JavaScript in web development?
Ans. JavaScript is used for form validation, interactive menus, dynamic content updates, event handling, and browser-based applications.
Q. How can JavaScript be included in an HTML page?
Ans. JavaScript can be included using a script element with embedded code or by linking an external JavaScript file using the src attribute.
Q. What is a variable in JavaScript?
Ans. A variable is a named binding used to store or refer to a value. JavaScript supports declarations using let, const, and var.
Q. What is the difference between let and const?
Ans. A let binding can be reassigned, while a const binding cannot be reassigned after initialization. Objects declared with const may still have mutable properties.
Q. What are JavaScript data types?
Ans. JavaScript has primitive types such as string, number, bigint, boolean, undefined, symbol, and null, along with objects.
Q. What is a function in JavaScript?
Ans. A function is a reusable block of code that can accept inputs, perform operations, and optionally return a value.
Q. What is an event in JavaScript?
Ans. An event is an occurrence, such as a click, key press, or form submission, that JavaScript can respond to.
Q. What is the DOM?
Ans. DOM stands for Document Object Model. It represents an HTML document as a structured tree of objects that scripts can access and modify.
Q. How can JavaScript select an HTML element by its ID?
Ans. The document.getElementById() method selects the element whose id matches the specified string.
Q. What is an array in JavaScript?
Ans. An array is an object used to store an ordered collection of values, which can be accessed using indexes.
Q. What is an object in JavaScript?
Ans. An object is a collection of properties, where each property associates a key with a value.
Q. What is the purpose of the if statement?
Ans. The if statement executes a block of code when its specified condition evaluates to true.
Q. What is a loop in JavaScript?
Ans. A loop repeatedly executes a block of code while its iteration conditions permit, such as with for or while loops.
Q. What is the difference between == and ===?
Ans. The == operator performs equality comparison with possible type conversion, whereas === compares without type conversion.
Q. What is the purpose of console.log()?
Ans. console.log() writes information to the browser or JavaScript runtime console, which is useful for debugging.
Q. What is form validation?
Ans. Form validation checks whether submitted or entered data meets specified requirements before it is processed.
Q. What is an arrow function?
Ans. An arrow function is a concise function expression written using the => syntax. It also uses lexical this binding.
Q. What is JSON?
Ans. JSON stands for JavaScript Object Notation. It is a text-based format for exchanging structured data.
Q. What is asynchronous JavaScript?
Ans. Asynchronous JavaScript allows certain operations, such as network requests, to be handled without blocking the main thread while waiting for completion.

🚀 Quick Access