Guide 01 / 4
JavaScript glossary
Give meaning to JavaScript terms by tying them to the recipe mini-blog.
Explain the concepts in your own words and recognise them in an example.
01 · Getting your bearings before you start
Step 3/6 of the “À table !” running project, a recipe mini-blog. Go at your own pace: read, reproduce, modify, then check.
The path and the outcome of this step
Let users search for a recipe by its title and duration, display the number of results and reset the filters without reloading the page. The same dataset runs through all six courses: Soupe de carottes (20 min), Salade de tomates (10 min), Tarte aux pommes (45 min).
Example
01. HTML : structurer trois recettes dans une page sémantique.
02. CSS : rendre le blog lisible sur mobile et sur ordinateur.
03. JavaScript : filtrer les recettes sans recharger la page.
04. PHP : produire les pages depuis des tableaux et traiter un formulaire.
05. MySQL : conserver les recettes dans une base relationnelle.
06. PDO : lire et ajouter des recettes depuis PHP avec des requêtes préparées.
Each course has four guides: glossary, essentials, workshop and resources. The complete files are at the end of the workshop.
Prerequisites and environment
Have finished HTML and CSS. Keep the mini-blog's index.html and style.css, with filtres, recherche, duree-max, compteur and aucun as identifiers. Check the data-titre and data-duree attributes of the three articles. Use a local HTTP server: for example python3 -m http.server 8080 if Python 3 is available.
Example
mini-blog/
index.html # HTML, CSS et JavaScript
style.css # ajouté à l’étape CSS
app.js # ajouté à l’étape JavaScript
public/ # pages PHP accessibles par HTTP
includes/ # fonctions, connexion et données PHP
database/ # scripts SQL
Create this working folder separately from the Technipédia course files. The example paths are relative to mini-blog/. Do not replace the HTML page of this platform.
The method: understand, reproduce, transform
Read a sheet, then type its example. Explain what changes on screen. Change one thing at a time and compare with the expected result. Keep a copy of the previous step before moving on.
Example
1. Je lis et je reformule.
2. Je reproduis dans mon mini-blog.
3. Je change une valeur ou une règle.
4. Je vérifie et j’explique le résultat.
Short snippets illustrate a concept; only the files announced as complete are to be copied as they are. Fragments are not to be concatenated into a single file.
02 · Naming and transforming data
JavaScript is a programming language. Here, it runs in the browser.
Statement and console
A statement asks for an action. The developer tools console lets you observe values and errors.
Example
console.log("Le mini-blog est prêt");
Only type code you understand into your own project's console.
const and let
const declares a variable that is not reassigned; let is used when its value must be reassigned, like a counter.
Example
const titre = "Soupe de carottes";
let visibles = 0;
visibles += 1;
const does not make an object's content immutable; it forbids replacing the stored reference.
Types of values
A string represents text; a number is used for calculation; a boolean is true or false; null here represents the absence of a result.
Example
const titre = "Soupe";
const duree = 20;
const rapide = true;
const elementAbsent = null;
Array and object
An array holds several values; an object gathers named properties. Objects suit structured recipes.
Example
const recette = { titre: "Soupe de carottes", duree: 20 };
const titres = ["Soupe", "Salade", "Tarte"];
console.log(recette.titre, titres[0]);
Array indexes start at 0.
Function, parameter and return
A function groups reusable processing. The parameter receives a piece of data; return sends back the result.
Example
function estRapide(duree) {
return duree <= 20;
}
console.log(estRapide(10)); // true
Condition and logical operator
if runs a block depending on a condition. && requires two true conditions; || requires at least one; ! inverts a boolean.
Example
const afficher = true && (20 <= 20);
if (afficher) { console.log("Visible"); }
=== compares without automatic type conversion. "20" === 20 is false.