How to learn and remember JavaScript: see, build and peg

By Kylo ยท ยท 11 min read

When I first started learning JavaScript, I may as well have jumped straight into machine learning. The outcome was the same: deep, dire confusion.

I believed I would eventually stop clicking the reveal solution and provide hint buttons. But as the weeks and months went by, my frustration grew.

  • I was still clicking provide hint
  • I still copy-pasted most of the code I "wrote"
  • My only projects were course projects
  • Heck, if AI assistants had existed back then, I would have let one write every line for me

Here is a very scientific chart of my confusion vs frustration:

A hand-drawn chart titled Learning JS. A red line labelled confusion climbs steadily from the start. A blue line labelled frustration stays low until the 1-3 months mark, then climbs right behind it.

If you have a similar chart, this guide is for you. It doesn't matter if yours covers 1-3 months or 5-10 years (not an uncommon story, and there are good reasons JavaScript is difficult).

The See, Build and Peg learning system

Here is the good news: your story has to start in the middle of frustration. It has to begin with deep, dire confusion. That's where the seeds of growth are planted, and where knowledge trees grow their roots. ๐ŸŒฑ

This is the system I used to break through my own JavaScript struggles. It's what I teach students of The Great Sync, and how I've coached junior developers in my teams. It has 3 parts:

  1. See the Model
  2. Build Sand Castles
  3. Peg the Washing

But before we dive in, there's an important foundation to lay.

You need two cars to learn JavaScript

I usually hate car analogies because there are a gazillion of them, but this one works, so please forgive me.

The first car is a race car ๐ŸŽ๏ธ: theory and coursework.

  • It's comfortable. Guided tutorials and courses take you step by step, give you direction, and even help you finish projects.
  • It carries the theory and industry patterns you need to get a job.

The second car is a slow truck ๐Ÿšš: self-guided project work.

  • It forces cognitive effort, which is the essential learning ingredient.
  • It makes you practise solving problems on your own.
Two cars seen from above on a race track heading to a JS checkered flag: a red car labelled theory and course work, and a blue car labelled projects and exercises.

Each demands its own time, dedication, consistency and accountability. But they are not built the same. Self-guided projects are slow and cumbersome, with no navigation system. Theory and coursework feels more productive, and the course chapters hand you a roadmap. It's more exciting too, like any race car.

But this isn't a race between them. You need both cars to gain confidence with JavaScript.

Don't negotiate with the Imp

Many people ask me for a faster way to master JavaScript. Let me tell you what happens when you look for a route around the hard work: you end up negotiating with the Imp.

A small green imp with tattered red wings, a patched wizard hat and curly red hair, rubbing his hands together deviously.

This little creature lives in The Great Sync. He loves convincing you that Learn JS in 1 hour videos will actually work. These days he has a new favourite line: with an AI assistant in every editor, why bother understanding the code? Just accept the suggestion.

Answers have never been closer. They're one prompt away. Yet confidence among learners is lower than ever, because every time you skip the thinking, you skip the learning. You end up with code that works but that you couldn't explain, change or rebuild.

The Imp is your imposter syndrome, and he's devious! There are no shortcuts to becoming a developer. (If he's whispering that you should give up altogether, read that first.)

The 4 stages of learning, and how to split your time

So how much time should each car get? It depends on where you are in your journey. These charts are a rough guide for 4 stages:

  1. First Weeks: you're a raw beginner.
  2. Fluency Building: JS is still new, and you're getting comfortable with the syntax.
  3. Mental Model Growth: an exciting period where you start making sense of what you've learnt and putting it into practice.
  4. Confidence Growth: your one objective is to apply JavaScript and build things without feeling like a total imposter.
A hand-drawn pie chart titled First Weeks. Almost all of it is theory and coursework, with a thin slice of exercises.
First weeks: 90-95% of your time goes on tutorials with guided exercises and challenges.
A hand-drawn pie chart titled Fluency Building. About two thirds is theory and coursework, and about a third is exercises.
Fluency building: to get comfortable writing code, spend at least a third of your time on exercises.
A hand-drawn pie chart titled Mental Model Growth. About half is theory and coursework, a third is exercises, and a small slice is projects.
Mental model growth: start your own projects and cut back on coursework. See the Model, below, helps this growth along.
A hand-drawn pie chart titled Confidence Growth. Projects fill most of it, with thin slices of theory and exercises.
Confidence growth: confidence comes from building lots of projects, 60-80% of your time. Theory doesn't stop, which is where Peg the Washing comes in.

See, Build and Peg is how you keep both cars driving. It begins with seeing the model.

Step 1: See the Model ๐Ÿ‘€

I didn't study computer science. I hated computers. I almost gave up learning JavaScript. Today I'm a full stack developer building commercial applications. How did that happen? ๐Ÿ˜‚

My breakthrough was finding a way to see JavaScript, and the bigger picture.

Without a translation or a change in perspective, every confusion, misunderstanding and misconception stays fixed. JavaScript turns into a brick wall ๐Ÿงฑ. A shift in perspective helps you connect the dots and get past it.

How your mental model evolves

Perspective has everything to do with your mental model. With a narrow point of view, progress is slow and the Imp is strong. But if you understand how your mental model evolves, and which stage it's in, you can make sure you're doing the right things to grow.

A hand-drawn rectangle titled At first, with a few sparse black dots and squiggles scattered across it.
At first, nothing feels connected. You're making marks on a blank canvas.
A hand-drawn rectangle titled After some courses, with solid squares, triangles and circles scattered around, surrounded by question marks.
After some courses, things take shape. It's chaotic and disconnected, and some parts are stronger than others.
A hand-drawn rectangle titled Copypasting and ChatGPT. The same shapes are now buried in a mess of tiny squiggles, dashes and question marks with no order.
Copy-pasting, or accepting AI code you don't understand, makes building faster. But the knowledge you gain is sparse and unconnected to what you already know. Avoiding thinking is the most damaging thing you can do to your mental model.
A hand-drawn rectangle titled With perspective, projects and cognitive effort. The shapes are grouped into clusters joined by colourful blue, yellow, green and pink lines.
With perspective, projects and cognitive effort, you start relating new things to what you already know.

What didn't work: memory tricks

When nothing would stick, I reached for memory techniques. I turned JavaScript into fun, exaggerated pictures. An array became an A-ray: a wizard's table of fruit and gem trays, labelled 0 to 3, with tools for sorting, searching, looping and filtering. I built memory palaces too.

A grey wizard creature in a starry hat stands behind a wooden table of trays. The top row holds fruit and the bottom row holds gems, each tray labelled 0 to 3. A caption reads: An A-ray, with tools for sorting, searching, looping and filtering.

It was fun. And it did not help one bit. I could recall my silly pictures, but JavaScript stayed as hard as ever.

What did work: taking code apart

So I went back to the drawing board. Instead of memorising facts, I started identifying the parts that make up code.

An isPrime function with its parts circled in red: the function keyword, the num parameter, the for keyword, the loop condition, i++ and the return keyword.

Circling each part made me investigate it. What does function actually create? Where does num come from? When does i++ run? And then I started noticing relationships between the parts.

The same isPrime function with red arrows linking its parts: from the function keyword out to new circles, from the for loop to the if statement inside it, and from i++ off the edge of the screen.

The deeper I went, the more questions I asked. I filled course notes and hand-drawn diagrams, mostly circles and squares, built silly projects and read books. Visualising those parts and their links built a consolidated understanding, and everything began to click.

That was the start of The Great Sync. Over time, those circles and squares grew into a three-dimensional universe that maps JavaScript concepts into a visual form I could understand, have fun with and, ultimately, remember ๐Ÿง .

The Great Sync model of JavaScript: three floating islands with lighthouses stacked above each other, joined by waterfalls that pour into a blue ocean and swirl down into an engine below.

Not an analogy, a model

Here's the key difference from my A-ray. The Great Sync doesn't memorise facts about JavaScript. It visualises how JavaScript behaves.

Take a simple function call:

function greet(language) {
    if (language === 'spanish') return 'Hola!';
    return 'Hello!';
}

greet('spanish');

Most courses focus on what this function does: it returns a greeting. The model shows how it behaves. Calling greet is an invocation. 'spanish' travels in as an argument. A brand new execution context is created, with its own local scope. The code runs, and the return value pours back out to where the function was called.

The greet function drawn as The Great Sync model: a ship labelled greet, an island of context with a lake labelled run time, a lighthouse labelled local scope, a waterfall labelled return, a figure labelled invocation, a boat of args and a small island labelled spanish. Text reads: everything is understood as one layer of a much bigger picture.

Every concept is one layer of a much bigger picture, and each new layer connects to the ones before it. This is the model the free chapters of Imagine JavaScript build, layer by layer.

The visual approach is a bridge between technical knowledge and abstract thinking. Once you understand a pattern deeply, you remember it without any mnemonic. After a while, you won't need to imagine anymore.

If you'd like the longer story, I talked about it on the CodeNewbie podcast (the show ended in 2024, but the archive is still there) and wrote about it for Smashing Magazine.

4 things you can do to grow your model

The Great Sync isn't the only way to gain a new perspective. Any time you learn something new, your job is to look for experiences that build on it. Here are 4 things I suggest.

1๏ธโƒฃ Ask questions and play in code playgrounds

Be your own JavaScript detective ๐Ÿ•ต๏ธ. Take the code you've just seen in a tutorial and poke holes in it. What happens if you tweak it slightly? What are you assuming?

A code playground is anywhere you can run JavaScript and see a console. Try the Snippets tab in the Sources panel of Chrome DevTools:

Chrome DevTools open on the Sources panel, with the Snippets tab selected and a new script snippet containing the comment: Write some code here.

Handy tip: keep a notes doc permanently open. Every time you meet some new code, spend 5 minutes listing questions about it. Then schedule an hour or two of playtime each week to answer them in a relaxed setting. If you bring an AI assistant along, ask it to quiz you, not to give you the answers.

2๏ธโƒฃ Listen to podcasts

Listening to code, without a screen, forces you to use your mind's eye. Beware: many podcasts focus on tools, libraries and frameworks. Look for episodes about concepts, like these:

3๏ธโƒฃ Talk JavaScript out loud

If you're stuck on a concept, start explaining the parts you do know. It must be out loud. Otherwise it stays in your head and is unlikely to give you a fresh perspective.

Handy tip: make flash cards. It may sound like school, but simple cards help you practise talking through questions like:

  • What is an execution context?
  • What's the difference between an argument and a parameter?
  • What is this?

Even writing the questions is valuable cognitive effort that helps you see things differently.

4๏ธโƒฃ My favourite: analogies and visual representations

Coming up with your own takes time (and the reward is SO worth it). Borrowing other people's is a faster way to gain a new perspective:

Step 2: Build sand castles

The second car needs fuel. Your learning journey should be littered with half-broken projects you wouldn't show your grandma: small, self-guided builds you make on your own, with no tutorial holding your hand. Like sand castles, they'll wash away, and that's the point. Step 2 shows you how to allocate the time, pick the projects and actually start: Build sand castles.

Step 3: Peg the washing

Once your sand castles work, most of the code gets left in a crumpled heap, like washing dumped on the floor. Step 3 is about tidying it up and building strong associations between everything you code, learn and get wrong, so it sticks: Peg the washing.

Actions to take right now

  1. Write down what you're currently learning.
  2. For each topic, spend 30 minutes finding resources that cover it, especially podcasts and visual explanations.
  3. In a notes app or notebook, write questions and thoughts about it, with code snippets you want to play with.
  4. Block time in your calendar for both cars, plus a weekly playtime session to immerse yourself.

Then keep going. The confusion is where it starts, not where it ends.