Unit summary
- JavaScript runs in the browser and adds behaviour to HTML and CSS.
- Variables hold values of different types, and operators combine them. Use === to compare.
- if, switch and loops control the flow of a program.
- Functions package reusable code with parameters and return values, and arrow functions are the short form.
- Events and listeners let a page respond to clicks, keys, forms and the window.
- The DOM is a live tree of nodes that scripts can find and change.
- Dialogs, the console and DOM changes are the ways to show output.
- Arrays, strings, objects, dates and maths have built-in tools for working with data.
Glossary
| Term | Meaning |
|---|---|
| Array | An ordered list of values, numbered from index 0. |
| Arrow function | A short way of writing a function using the => symbol. |
| Client-side scripting | Code that runs in the user's browser instead of on the web server. |
| Conditional statement | A statement that runs code only when a condition is true. |
| Data type | The kind of value stored, such as a number, a string or a boolean. |
| Dialog box | A small window made by alert, prompt or confirm that waits for the user to respond. |
| DOM | The Document Object Model, a tree of objects that represents the page in the browser. |
| DOM manipulation | Changing the content, attributes, styles or structure of a page through the DOM. |
| DOM node | One item in the DOM tree, such as an element, an attribute or a piece of text. |
| Event | An action or occurrence on a page, such as a click, a key press or a page load. |
| Event listener | A function that runs when a chosen event happens on an element. |
| Function | A named block of code that can be run many times and may return a value. |
| JavaScript | A programming language that runs in the browser and makes web pages interactive. |
| Loop | A statement that repeats a block of code while a condition holds. |
| NodeList | A list-like collection of nodes, returned by methods such as querySelectorAll. |
| Object | A collection of named values called properties, written with braces. |
| Operator | A symbol, such as + or ===, that works on one or more values. |
| Variable | A named place that stores a value which a program can use and change. |
Question bank
Short Answer Questions (2 marks each)
- What is JavaScript? Where does it run?
- Differentiate between let and const.
- List the primitive data types of JavaScript.
- Differentiate between == and ===.
- What is the use of the break statement?
- What is an arrow function? Give an example.
- What is an event listener?
- What is the DOM?
- Differentiate between textContent and innerHTML.
- What do the filter and map methods do?
Medium Answer Questions (5 marks each)
- Explain the ways of embedding JavaScript in an HTML page.
- Explain the data types and operators of JavaScript with examples.
- Explain the if, switch and loop statements with examples.
- Explain function declaration, function expression and arrow function with examples.
- Explain the methods of finding elements in the DOM.
- Explain alert, prompt, confirm, console.log and document.write.
Long Answer Questions (15 marks each)
- Explain functions in JavaScript with parameters, return values and arrow functions. Write a set of reusable maths functions and show their output.
- Explain events and event handling. Build a page with a button counter, a keyboard event and a form event, and explain each listener.
- Explain the DOM tree, the methods to select nodes and the ways of changing content, attributes and styles. Build a dynamic to-do list.
- Explain arrays, strings, objects, Date and Math with examples. Write a program that filters a list of student names and marks.
Sources
- Official BCA syllabus (NEP 2025 scheme), Web Application Development, course code 25BCA405DS04, Unit III
