JavaScript Notes
A beginner reference with practice prompts and pitfalls to check.
Download editable TXTValues and variables
Use const when the variable binding should not be reassigned; use let when reassignment is needed. Objects stored in const can still be mutated. Learn strings, numbers, booleans, null and undefined.
Functions
Describe a function's inputs, output and side effects. Prefer small functions you can test with clear examples.
Collections
Arrays represent ordered values. Objects represent properties. Practise map for transformation, filter for selection and reduce for accumulation. Check whether a method mutates the original array.
Equality and missing values
Understand strict equality and type conversion. Check missing values explicitly when zero or an empty string is a valid input.
Async work
A promise represents work that may complete later. async / await supports reading promise-based code in sequence. Handle rejected promises and show useful error messages.
Browser interactions
Read form inputs, validate them and respond to events. Use textContent for untrusted text rather than inserting it as HTML. Keep API secrets out of client-side code.
Practice
- Count word frequencies in a sentence.
- Filter a product list by price.
- Calculate a total from an array of quantities and prices.
- Build a form with required-field messages.
- Fetch sample data and handle loading, success, empty and error states.
Review checklist
Check types, null values, accidental mutation, unhandled promises and repeated submissions. Explain your code without reading a tutorial.