Reading and exploring existing code is on of the best ways to learn programming (!). Sure, it’s important to write a lot of code, get stuck, fix your problems, and build cool things. But how can you expect to write great code if you’ve never seen any before?!
Learning to read, explain, and modify existing code is a crucial skill to learn early in your programming life. Besides being an effective learning strategy, this is also what you’ll spend most of your time doing as a programmer.
Programming is hard. It’s better to study slowly and learn from your mistakes than to code quickly and not understand what you wrote.
Learning to read your code aloud and to pronounce the strange syntax in JavaScript is super important! Practice alone, practice with a friend, record yourself and play it back. When you watch video tutorials pay close attention and practice repeating how the teacher pronounces their code.
Some links:
Writing code from an empty file is actually not the best way to learn programming. Writing programs is your end goal, but it’s not the best way to get there.
Think of programming like learning a new language, if you’re learning Dutch you don’t start by writing articles for a newspaper! First you’ll start by learning some grammar and vocabulary, reading small texts, and practicing simple conversations.
You should use the same approach when learning to program. Each time you’re learning a new language feature or programming technique, taking some take some time to study code that someone else has written using the new concepts.
PRIMM is a good strategy for getting the most out of every example you study:
Programs are all about data. Understanding how the programming language stores and uses the data is key to becoming a confident programming.
Studying programs line by line in a visualization tool such as JS Tutor, the debugger or Learn With Trace will help you build the foundations you need to write and debug your own programs.
If you can ask and answer these questions for every step in your program’s execution then you are good to go! Studying this way will take more time and may feel slow, but in the long run it’s the fastest way to learn JS.