Unit summary

  • JavaScript, created in 1995 and standardised as ECMAScript, makes web pages interactive.
  • Output uses alert, document.write, innerHTML and console.log; input uses prompt and confirm.
  • Variables are declared with let and const; types are dynamic; arrays have powerful methods.
  • Functions organise code, as declarations, expressions or arrow functions.
  • Events such as click, keyup and change are handled with addEventListener and the event object.
  • The DOM is a tree of the page that scripts select, traverse and change.
  • The Date object and string methods handle dates and text.

Glossary

Term Meaning
addEventListener A method to attach event handlers.
alert A pop-up message box.
Array An ordered, indexed list of values.
Arrow function A short function written with =>.
console.log Output to the developer console.
const A block-scoped constant declaration.
Date object An object representing a moment in time.
DOM The Document Object Model tree.
Dynamic typing Types decided by current values.
ECMAScript The standard that defines JavaScript.
Event A user or browser action.
Event bubbling Events rising to parent elements.
Event handler A function run when an event occurs.
Function A reusable named block of code.
JavaScript The scripting language of the web.
let A block-scoped variable declaration.
prompt An input box that returns text.
querySelector Selects the first element matching a CSS selector.
Template literal A string in back quotes with ${} expressions.

Question bank

Short Answer Questions (2 marks each)

  1. What is JavaScript?
  2. Name three ways of producing output in JavaScript.
  3. What does prompt() return?
  4. Distinguish let and const.
  5. Distinguish == and ===.
  6. What is an arrow function?
  7. What is an event handler?
  8. What is the DOM?
  9. What does querySelectorAll() return?
  10. What does getMonth() return for December?

Medium Answer Questions (5 marks each)

  1. Explain the output system of JavaScript.
  2. Explain variables, data types and arrays in JavaScript.
  3. Explain functions with examples.
  4. Explain events and event handling.
  5. Explain DOM traversal with an example.
  6. Explain the Date object and string methods.

Long Answer Questions (15 marks each)

  1. Explain JavaScript, its placement in a page, and its output and input system.
  2. Explain variables, data types, arrays and functions in JavaScript, with examples.
  3. Explain events and event handling with examples of five events.
  4. Explain the Document Object Model and its traversal and modification, with date and string handling.

Sources

  • Official BCA syllabus Web Technologies, course code 25BCA402SEC02, Unit III