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)

  1. What is JavaScript? Where does it run?
  2. Differentiate between let and const.
  3. List the primitive data types of JavaScript.
  4. Differentiate between == and ===.
  5. What is the use of the break statement?
  6. What is an arrow function? Give an example.
  7. What is an event listener?
  8. What is the DOM?
  9. Differentiate between textContent and innerHTML.
  10. What do the filter and map methods do?

Medium Answer Questions (5 marks each)

  1. Explain the ways of embedding JavaScript in an HTML page.
  2. Explain the data types and operators of JavaScript with examples.
  3. Explain the if, switch and loop statements with examples.
  4. Explain function declaration, function expression and arrow function with examples.
  5. Explain the methods of finding elements in the DOM.
  6. Explain alert, prompt, confirm, console.log and document.write.

Long Answer Questions (15 marks each)

  1. Explain functions in JavaScript with parameters, return values and arrow functions. Write a set of reusable maths functions and show their output.
  2. Explain events and event handling. Build a page with a button counter, a keyboard event and a form event, and explain each listener.
  3. Explain the DOM tree, the methods to select nodes and the ways of changing content, attributes and styles. Build a dynamic to-do list.
  4. 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