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)
- What is JavaScript?
- Name three ways of producing output in JavaScript.
- What does prompt() return?
- Distinguish let and const.
- Distinguish == and ===.
- What is an arrow function?
- What is an event handler?
- What is the DOM?
- What does querySelectorAll() return?
- What does getMonth() return for December?
Medium Answer Questions (5 marks each)
- Explain the output system of JavaScript.
- Explain variables, data types and arrays in JavaScript.
- Explain functions with examples.
- Explain events and event handling.
- Explain DOM traversal with an example.
- Explain the Date object and string methods.
Long Answer Questions (15 marks each)
- Explain JavaScript, its placement in a page, and its output and input system.
- Explain variables, data types, arrays and functions in JavaScript, with examples.
- Explain events and event handling with examples of five events.
- 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
