Workspace

JavaScript

browser apps automation and API glue

Definition first

What JavaScript means

JavaScript is a programming language for writing exact instructions, often used for browser apps automation and API glue. Start with one mental model: input goes through steps and becomes output.

Minimum run factsFile app.jsRun node app.jsHabit Use console.log and DevTools before adding abstractions
Program

An ordered set of instructions. It reads input, follows rules, and produces output.

Value and variable

A value is data. A variable is the name you use to hold and reuse that data.

Function

A named piece of work. It takes input, does one job, and can return a result.

Runtime

Browser console or Node.js is the place that actually runs code from app.js.

First readable code

Values and variables

const let string number boolean object array
const score = 40 + 2;
console.log(score);
Output 42

Language lineage

JavaScript family tree

See where JavaScript comes from, which languages feel close, and what to learn next.

roots
CJavaSchemeSelf
currentJavaScriptWeb scripting family
familyWeb scripting family
best used for

front end behavior, Node.js scripts, API glue, and quick product experiments

Zero base path

1Read one rule2Predict output3Type from memory4Run checklist5Repeat with one change

Question bank

Search before practice

Pick a stage or search across the open programming bank. Jump straight to the matching drill.

18 matching questions
Q 1ChoiceStage 1 definitions

JavaScript practice 1

JavaScript question 1. Choose the statement that matches constant variable.

Q 2ChoiceStage 1 definitions

JavaScript practice 2

JavaScript question 2. Choose the statement that matches function return.

Q 3ChoiceStage 1 definitions

JavaScript practice 3

JavaScript question 3. Choose the statement that matches array mapping.

Q 4ChoiceStage 1 definitions

JavaScript practice 4

JavaScript question 4. Choose the statement that matches async await.

Q 5ChoiceStage 1 definitions

JavaScript practice 5

JavaScript question 5. Choose the statement that matches constant variable.

Q 6ChoiceStage 1 definitions

JavaScript practice 6

JavaScript question 6. Choose the statement that matches function return.

Q 7ChoiceStage 1 definitions

JavaScript practice 7

JavaScript question 7. Choose the statement that matches array mapping.

Q 8ChoiceStage 1 definitions

JavaScript practice 8

JavaScript question 8. Choose the statement that matches async await.

Q 9ChoiceStage 1 definitions

JavaScript practice 9

JavaScript question 9. Choose the statement that matches constant variable.

Q 10ChoiceStage 1 definitions

JavaScript practice 10

JavaScript question 10. Choose the statement that matches function return.

Q 11ChoiceStage 1 definitions

JavaScript practice 11

JavaScript question 11. Choose the statement that matches array mapping.

Q 12ChoiceStage 1 definitions

JavaScript practice 12

JavaScript question 12. Choose the statement that matches async await.

Q 13ChoiceStage 1 definitions

JavaScript practice 13

JavaScript question 13. Choose the statement that matches constant variable.

Q 14ChoiceStage 1 definitions

JavaScript practice 14

JavaScript question 14. Choose the statement that matches function return.

Q 15ChoiceStage 1 definitions

JavaScript practice 15

JavaScript question 15. Choose the statement that matches array mapping.

Q 16ChoiceStage 1 definitions

JavaScript practice 16

JavaScript question 16. Choose the statement that matches async await.

Q 17ChoiceStage 1 definitions

JavaScript practice 17

JavaScript question 17. Choose the statement that matches constant variable.

Q 18ChoiceStage 1 definitions

JavaScript practice 18

JavaScript question 18. Choose the statement that matches function return.

Multiple choice

JavaScript practice 1

Q 1Choicenew

JavaScript question 1. Choose the statement that matches constant variable.

const total = 42;
console.log(total);

Reference

Patterns for app.js

Browser console or Node.jsnode app.js
Recall from memoryRead a small point then write it back without looking
Trace the codeWrite variable values line by line before you run the answer
Type it yourselfCopy less type more and fix one small error at a time

const let string number boolean object array

Values and variables

const score = 40 + 2;
console.log(score);
  • Prefer const first
  • Use let only when the value changes
  • Inspect values with console.log

input output return reusable actions

Functions

function add(a, b) {
  return a + b;
}
console.log(add(2, 3));
  • Name functions with verbs
  • Return values instead of printing inside every function
  • Keep one function focused

fetch promise await error handling

Async APIs

async function load() {
  return await Promise.resolve("ready");
}
load().then(console.log);
  • Check network errors
  • Await the promise before reading data
  • Keep API parsing separate