JavaScript - interactive pages (INF.03)
Bring your page to life - DOM, events and form validation
A JavaScript course within the INF.03 scope: language basics, DOM manipulation, event handling and client-side form validation. The exercises bring the pages from the HTML and CSS courses to life.
Course modules
M1 Introduction to JavaScript 4 lessons
-
What is JavaScript
History, its role on the internet, JavaScript vs HTML vs CSS. How it works in the browser.
-
Adding JS to HTML
The <script> tag, the src attribute, defer vs async, good practices for placing scripts.
-
JS syntax: statements, comments
Semicolons, case sensitivity, single-line and block comments, white space.
-
console.log and debugging
The browser console, console.log / warn / error, debugger, working with DevTools.
M2 Variables, types, operators 4 lessons
-
Variables: let, const, var
Declaring variables, the differences between let, const and var, hoisting, good practices.
-
Data types in JavaScript
string, number, boolean, null, undefined, bigint, symbol. The typeof operator.
-
Operators and comparisons (== vs ===)
Arithmetic, logical and assignment operators. The difference between == and ===. Falsy values.
-
Type conversions and template strings
parseInt, parseFloat, Number(), String(), Boolean(). Template literals - backticks and interpolation.
M3 Control structures 4 lessons
-
if, else, else if, the ternary operator
Conditional statements, nesting, the ternary operator. Readable decision-making code.
-
switch-case
The switch statement, case, default, break. When to use switch instead of if-else.
-
Loops: for, while, do-while
The classic for loop, while with a condition, do-while. Counters, iteration, the risk of an infinite loop.
-
for...of, for...in, break, continue
Iterating over arrays (for...of) and objects (for...in). Interrupting loops: break, continue.
M4 Functions 4 lessons
-
Function declaration, parameters, return
Creating functions with the function keyword, parameters with default values, the return statement.
-
Function expressions and arrow functions
Functions as values, function expressions, the arrow function (=>), shorthand syntax.
-
Variable scope and closures
Global and local scope, block scope (let/const), closures. Typical traps.
-
Callbacks - an introduction
A function as an argument, setTimeout, setInterval. Callbacks in events and array methods.
M5 Arrays and objects 4 lessons
-
Arrays: creating, indexes, push/pop methods
Creating arrays, access by index, length, push, pop, shift, unshift, splice.
-
forEach, map, filter, find, sort
Iterating and transforming arrays. forEach, map, filter, find, findIndex, sort, includes.
-
Objects: properties, methods, iteration
The object literal, access with . and [], adding/removing properties, methods, for...in.
-
JSON: stringify, parse
The JSON format, JSON.stringify(), JSON.parse(), working with data from an API and localStorage.
M6 DOM: selecting and changing elements 6 lessons
-
What is the DOM - the document tree
The Document Object Model: a tree of nodes, the browser builds the DOM from HTML, inspecting in DevTools.
-
querySelector, getElementById, querySelectorAll
Methods of selecting elements: getElementById, querySelector, querySelectorAll, HTMLCollection vs NodeList.
-
textContent, innerHTML (and XSS)
Changing text with textContent. innerHTML and the risk of XSS - when to use it with care.
-
setAttribute, getAttribute, value, src
Reading and writing attributes. value for form fields, src for images, href for links.
-
classList (add/remove/toggle), style
classList.add, remove, toggle, contains. Inline style through element.style. Classes vs inline CSS.
-
createElement, appendChild, remove
Creating nodes dynamically: createElement, textContent, appendChild, insertBefore, remove.
M7 Events 4 lessons
-
The event model, addEventListener
What an event is. addEventListener(type, handler), removeEventListener. Event bubbling.
-
click, dblclick, mouseover, mouseout
Mouse events: click, dblclick, mouseenter, mouseleave, mouseover, mouseout. Practical examples.
-
keydown, keyup; submit, change, input, focus, blur
Keyboard and form events. keydown, keyup, change, input, focus, blur, submit.
-
event.target, preventDefault, stopPropagation
The event object: target, currentTarget, type. Blocking the default action, stopping bubbling.
M8 Form validation 5 lessons
-
Why client-side validation vs server-side
Form UX, the difference between client and server validation, why both are necessary.
-
Reading field values: value, checked, empty fields
Getting the values of inputs, textarea, select. checkbox.checked. Checking for empty fields.
-
Validation: numbers, email, length, RegExp
isNaN, Number(), test() with regular expressions. Validating email, phone number, password length.
-
Showing errors next to fields, blocking submit
Inserting error messages into the DOM, error styles, event.preventDefault() on errors.
-
Complete form validation
A complex form with many fields - the full flow: validation, errors, blocking and confirmation.
M9 Exam revision 2 lessons
-
The most common JS traps from CKE exam sheets
Typical exam mistakes: == vs ===, hoisting, undefined vs null, syntax errors, event order.
-
Mini-sheets: bring the page to life per the task
A simulation of an INF.03 exam task: bringing a ready-made HTML/CSS page to life with JS code.