T0 Learning to learn · Lesson 4
Reading the docs, and knowing your versions
How to read a reference page fast, read a syntax line, learn any method in five minutes, read version numbers and Node's release lines, and check whether a feature works in every browser.
- find a method's page on MDN and read its parts in the right order
- read a syntax line: required and optional parameters, and the return value
- test what a page says, and know what to do when a run disagrees
- read MAJOR.MINOR.PATCH, and choose a Node version for real work
- check a feature with the Baseline label, the compatibility table and typeof
The back cover
Every tool a programmer uses comes with a written description of how it works, called its documentation. Nobody reads it from the first page to the last. A good developer looks up one thing, finds the right part of the page in seconds, and tries what it says with a line of code.
These pages show how a reference page is laid out, how to read the short line that shows how a method is called, and a five-minute routine for learning any new method. They also explain the three numbers of a version, such as 22.23.1, and why the version in use matters.
The last part is about browsers. A feature can be part of the language and still fail on an old phone, so the docs say which browsers support it, and a program can check for itself.
Before you start
The story: Three manuals
Ilse sends you to the Archive with a note: "The lamp-script manual. The right one." The Archive is a hall of shelves taller than houses, and an archivist in grey leads you to the lamp manuals.
There are three: a thick green one, a thin red one, and a new blue one that still smells of ink. They disagree. The green one says a lamp command takes two parts. The blue one says three.
Corin, who came along to help, has already copied a page from the green one, and his lamp will not light. Which manual is telling the truth?
No developer remembers every job of every value. Good developers know how to look a job up, read its page quickly, test what it says, and know which version of a tool the page is about. That is this lesson. It builds on these ideas; each has a tiny example.
| What you already know | A tiny example | Where it comes back |
|---|---|---|
| A method is a job a value can do, run with a dot and brackets. | "chai".toUpperCase() gives CHAI. | Reference pages describe one method each. |
| A property is information a value carries. | "chai".length is 4. | Pages list properties as well as methods. |
| An argument is a value handed to a call inside its brackets. | In toFixed(2), the argument is 2. | A page says which arguments a method accepts. |
| RangeError means a number was out of range. | (5.678).toFixed(200) throws one. | A page lists the errors a method can throw. |
| === and typeof check a value and its type. | typeof "5" === "string" is true. | Testing what a page claims, in one line. |
| MDN keeps a page for every error message. | Lesson 2 read its page on Cannot read properties. | MDN keeps a page for every method too. |
| The version line in Node's report. | Node.js v22.23.1. | This lesson reads the three numbers in it. |
| Engines differ. | V8 in Chrome and Node, SpiderMonkey in Firefox, JavaScriptCore in Safari. | A feature may work in one browser before the others. |
| A dictionary entry has a fixed layout. | word, how to say it, part of speech, meanings, examples. | A reference page has a fixed layout too, and reading it fast means knowing the layout. |
| Phone software updates have version numbers. | An app goes from 4.2 to 4.3, or from 4 to 5. | Version numbers follow rules that tell you how big a change is. |
By the end of this lesson you will be able to:
- find the page for any JavaScript method on MDN and read its parts in the right order;
- read a syntax line, telling required parameters from optional ones, and say what the method gives back;
- test what a page says with a tiny program, and know what to do when the two disagree;
- read a version number such as 22.23.1, and choose a Node version for a real project;
- check whether a feature works in every browser, with MDN's compatibility table and Baseline label.
In one line
This lesson is about looking things up well: it needs only methods, arguments, typeof and === from the earlier lessons.
Reading a reference page
At a glance
Documentation, or the docs, is the written description of how a tool works. It comes in three kinds. A tutorial teaches a beginner step by step, a guide explains one topic in depth, and a reference describes one thing, such as one method, exactly and briefly. References are what developers look up every day, and MDN is the best-known one for the web.
Every MDN page for a method has the same parts in the same order: the name, a Baseline label, a Try it example, Syntax, Parameters, Return value, Exceptions, a Description with Examples, Specifications and a table of browsers. For most look-ups only four of them matter. A claim worth relying on is then tested with a one-line program.
Take a guess: A reference page has about ten parts: how many of them does a quick look-up usually need?
A dictionary is not read from the first page to the last. You look up one word, glance at how to say it, find the meaning you need, and read one example. Developers use documentation the same way. The skill is knowing the layout of a page, so that your eyes go straight to the part you need.
The written description of how a tool works, made by the people who build it or by a trusted reference such as MDN. Developers call it the docs.
Documentation comes in three kinds. A tutorial teaches a beginner step by step, like these lessons. A guide explains one topic in depth. A reference describes every detail of one thing, such as one method, very exactly and very briefly. This lesson is about reading references, because they are what you look up every day.
The parts of an MDN page
Search for "MDN toFixed" and the first result is the page called Number.prototype.toFixed(). Every MDN page for a method has the same parts, in the same order. Here they are for toFixed, as the page stood on 26 October 2026.
| Part | What it says for toFixed | Read it when |
|---|---|---|
| The name | Number.prototype.toFixed(): a job that every number has | always: it says which kind of value has the job |
| Baseline label | Widely available: it has worked across browsers since July 2015 | you need to know whether all browsers can run it |
| Try it | a small runnable example | you want to see it work in ten seconds |
| Syntax | toFixed() and toFixed(digits) | always: how to write the call |
| Parameters | digits, optional: the number of digits after the decimal point, from 0 to 100; left out, it is 0 | always: what each argument means |
| Return value | a string with the number in fixed-point notation | always: what you get back, and its type |
| Exceptions | RangeError if digits is not between 0 and 100; TypeError if it is run on something that is not a number | an error mentions the method |
| Description and Examples | how it rounds, with examples, including a surprising one | the short parts were not enough |
| Specifications | the section of the ECMAScript standard that defines it | you need the final word on a detail |
| Browser compatibility | a table of which browser versions support it | you must support older browsers |
For most look-ups you read only four parts: the name, Syntax, Parameters and Return value. They take less than a minute. The rest is there for the day you need it.
About the word prototype
Number.prototype.toFixed reads as "the toFixed job that every Number has". The word prototype names the shared set of jobs that all values of one kind can use. The JavaScript steps explain how it works; for now, read it as "every".
Test what the page says
A reference page makes exact claims. Each one can be tested in a line. Testing them fixes them in your memory far better than reading alone, and now and then it shows you that you misread the page.
console.log((5.6).toFixed());
console.log(typeof (5.6).toFixed(1));
6
string
The first line tests the claim left out, digits is 0: no argument, so 5.6 is rounded to no places at all, 6. The second tests the return value is a string: typeof says string. Both claims hold. That second one matters: (5.6).toFixed(1) + 1 joins text instead of adding, so turn the result back into a number with Number(...) before doing more sums with it.
Worked example 1
The page's Exceptions part says toFixed throws a RangeError if digits is not between 0 and 100. Test both edges and one value outside.
What we have: the claim: 0 to 100 is allowed, inclusive
What we need: three runs that confirm it
The plan: try exactly 0, exactly 100, and 101
console.log((2.5).toFixed(0));
console.log((2.5).toFixed(100).length);
console.log((2.5).toFixed(101));
3
102
Uncaught RangeError: toFixed() digits argument must be between 0 and 100
at line 3
- 0 works and rounds 2.5 to 3. 100 works: the text is 2, the point and 100 digits, 102 characters, so the length is printed instead of the long number.
- 101 throws the RangeError the page promised.
The page is right: 0 and 100 work, and 101 throws a RangeError.
Check: inclusive means both edges are allowed, and both edge runs printed a value, while 101 failed.
Worked example 2
MDN's Examples part says that (2.55).toFixed(1) gives 2.5, not 2.6. Test it, and explain it with what lesson 1 taught about decimals.
What we have: the page's surprising example
What we need: a test, and the reason
The plan: run it beside a value that rounds the expected way
console.log((2.55).toFixed(1), (2.45).toFixed(1), (2.56).toFixed(1));
2.5 2.5 2.6
- 2.55 cannot be stored exactly in binary, just as 0.1 could not. The computer keeps the nearest value it can, which is a tiny bit below 2.55, so it rounds down.
- 2.45 is stored a tiny bit above, so it rounds up to 2.5 as well. 2.56 is far enough from the halfway point to round up as expected.
The page is right: 2.55 gives 2.5, because 2.55 is stored as a value a hair below 2.55.
Check: the explanation is the same decimal surprise as 0.1 + 0.2 in lesson 1; for money, count in paise to avoid it.
When you are stuck: a reference page that feels too dense
Read only four parts first: the name, Syntax, Parameters, Return value.
Copy the Try it example into a code block and run it; change one thing and run again.
Turn each claim you need into a one-line test, as in this section.
If the page is still too dense, search for a tutorial or a guide on the same topic first, then come back to the reference.
Your turn
Which four parts of an MDN page do you read for most look-ups?Tap to reveal
- They tell you what it is, how to write it, what to give it and what you get back.
The name, Syntax, Parameters and Return value.
console.log((9.99).toFixed(), typeof (9.99).toFixed());
What does this print? Say your answer aloud first, then press Run or tap to reveal.Tap to reveal
10 string
- Left out, digits is 0, so 9.99 is rounded to a whole number: 10.
- The return value is a string.
It prints 10 string.
What does the word prototype in Number.prototype.toFixed tell you, for now?Tap to reveal
- It names the jobs shared by all values of one kind.
That every number has the toFixed job.
Did you know?
The first Unix manual listed its own bugs
In the first two years of Unix, an operating system, no documentation existed at all. Then came the Unix Programmer's Manual, dated 3 November 1971, written by Dennis Ritchie and Ken Thompson. Its pages had a part called BUGS. One entry admitted that the clock counted sixtieths of a second in a number that would run out after only about 2.5 years. Ritchie later wrote that they had even anticipated the millennium bug.
Why it fits here: A good reference says what a tool does badly as well as what it does well, and that part is worth reading before relying on it.
Sources: Dennis Ritchie's pages at Nokia Bell Labs: the Unix Manual, first edition; Wikipedia: Man page
The first website was a manual
The web was born at CERN, a physics laboratory, and the very first website can still be visited there, at info.cern.ch. Its front page described the World Wide Web project itself: a plan to give universal access to a large universe of documents. Everything about the project was linked from that one page, from a summary to the mailing lists and a page of frequent questions. The first website was, in other words, the web's own documentation.
Why it fits here: The web began as a set of pages explaining how the web works, which is the kind of reference this topic reads.
Sources: CERN: info.cern.ch, home of the first website; CERN: the first website's front page, The World Wide Web project
In one line
A reference page has a fixed layout: read the name, Syntax, Parameters and Return value first, and test each claim you rely on with a one-line program.
Reading a syntax line
At a glance
A syntax line shows how a method is called, like a form with named boxes. Each box is a parameter: a named slot waiting for a value. The value placed in it at the call is the argument. When MDN shows a method on two lines, once without a parameter and once with it, that parameter is optional and may be left out.
Order matters: the first argument fills the first parameter, and the second fills the second. The page also says what comes back, and of what type, such as a new string. Methods that pick out one character count from 0, so the first character is at index 0 and the second at index 1.
Take a guess: In the word chai, which letter sits at index 1: c or h?
A railway reservation form has boxes: name, age, from, to, date. Some are marked with a star because you must fill them; some can be left empty and get a sensible default. A syntax line is the same kind of form for a method: it names the boxes, which ones you must fill, and in what order.
A named slot in a method's syntax line, waiting for a value. The value you put in it when you call the method is the argument. In toFixed(digits), digits is the parameter; in (2.5).toFixed(1), 1 is the argument.
MDN shows each way of calling a method on its own line. A method with an optional parameter is shown twice: once without it and once with it.
| A syntax line | Read it as |
|---|---|
toFixed() and toFixed(digits) | digits is optional: call it with nothing, or with one number |
repeat(count) | count is required: one number |
padStart(targetLength) and padStart(targetLength, padString) | targetLength is required; padString is optional and comes second |
at(index) | index is required: which character, counting from 0 |
The order of arguments matters. The first argument goes into the first parameter, the second into the second. Swap them and the method gets a value it did not expect.
A method met through its page: padStart
A shop prints order numbers with five digits, as 00042, so that they line up in a list. MDN's page for String.prototype.padStart() says: it pads the string from the start with another string, repeated, until it reaches targetLength. The pad string is optional and is a space if left out. The return value is the new, longer string. Test each claim:
console.log("42".padStart(5, "0"));
console.log("42".padStart(5) + "|");
console.log("Rice".padStart(2));
00042
42|
Rice
With "0" it pads with zeros to five characters. Without a pad string it pads with spaces; the | at the end shows where the spaces end. And if the string is already longer than targetLength, it comes back unchanged: that last fact was in the page's Description, and the test confirmed it.
Its partner, padEnd, pads at the end. Together they line up a receipt:
console.log("Rice".padEnd(12, ".") + "650".padStart(6, "."));
console.log("Toor dal".padEnd(12, ".") + "180".padStart(6, "."));
console.log("Tea".padEnd(12, ".") + "95".padStart(6, "."));
Rice...........650
Toor dal.......180
Tea.............95
Counting from zero
The page for at(index) says that index counts from 0, and that a negative index counts back from the end. Counting from 0 is a habit of almost every programming language: the first character is at index 0, the second at index 1.
console.log("chai".at(0), "chai".at(1), "chai".at(-1), "chai".at(9));
c h i undefined
Index 0 is c and 1 is h. -1 is the last character, i. And the page's Return value part says that an index outside the string gives undefined, not an error: index 9 tests that.
A common mistake
Counting the first character as 1. "chai".at(1) is h, the second character, not c. Lesson 2's columns counted from 1, but indexes in code count from 0. When a result is one place off, check which way you counted.
Worked example 3
A customer's mobile number must be shown with only its last 4 digits visible: XXXXXX3210. Find a method on MDN that gives the last characters of a string, read its syntax line, and use it.
What we have: the number 9876543210 as text, and MDN's page for slice: slice(indexStart) and slice(indexStart, indexEnd); a negative index counts from the end
What we need: the text XXXXXX3210
The plan: take the last 4 characters with slice, then put 6 X marks in front with padStart
const mobile = "9876543210";
const last4 = mobile.slice(-4);
console.log(last4);
console.log(last4.padStart(10, "X"));
3210
XXXXXX3210
slice(-4)starts 4 from the end and, with no indexEnd, goes to the end: 3210.padStart(10, "X")fills it out to 10 characters with X marks at the start.
XXXXXX3210, made with slice(-4) and padStart(10, "X").
Check: the result has 10 characters, as the number did, and its last four are the number's last four.
Another way: "X".repeat(6) + mobile.slice(-4) gives the same text: repeat makes the six X marks, + joins.
Worked example 4
Two developers read the syntax line padStart(targetLength, padString). One writes "7".padStart("0", 3). What happens, and why?
What we have: a call with the two arguments swapped
What we need: the result, and the fix
The plan: put each argument in its slot, in order, and ask what the method sees
console.log("7".padStart("0", 3) + "|");
console.log("7".padStart(3, "0"));
7|
007
- In the first call, targetLength gets the text 0, which counts as 0, and the string 7 is already longer than 0, so it comes back unchanged. The 3 sits in the padString slot, unused.
- In the second, the arguments are in the order of the syntax line.
With swapped arguments it returns 7 unchanged; in the right order it gives 007.
Check: the syntax line puts targetLength first, and the fixed call follows it.
A path that fails: trusting that no error means it worked. The swapped call threw nothing; only the output showed the slip, which is why every claim is worth a one-line test.
When you are stuck: a syntax line
Count the parameters. Find which are optional: they appear in one line and not in another.
Match your arguments to the parameters in order: first to first, second to second.
Read Return value: what type comes back? Test it with typeof.
Copy the page's first example, run it, then change one argument at a time.
Your turn
console.log("5".padStart(3, "0"), "abc".at(-2));
What does this print? Say your answer aloud first, then press Run or tap to reveal.Tap to reveal
005 b
- padStart fills 5 out to 3 characters with zeros: 005.
- at(-2) counts two back from the end of abc: b.
It prints 005 b.
In slice(indexStart, indexEnd), which parameter is optional, and how can you tell?Tap to reveal
- MDN shows slice(indexStart) and slice(indexStart, indexEnd) on separate lines.
indexEnd: there is a syntax line without it.
What is the difference between a parameter and an argument?Tap to reveal
- One is the named slot in the syntax line; the other is the value you put in it.
The parameter is the slot (digits); the argument is the value given (2).
Did you know?
Eleven lines that stopped thousands of builds
In March 2016 a programmer, Azer Koçulu, removed more than 250 of his packages from npm, the store that JavaScript projects install code from. One of them was left-pad: a few lines that pad the left-hand side of a string with zeroes or spaces. Thousands of projects relied on it, Node and Babel among them, and they suddenly failed to install. The next year, ECMAScript 2017 gave every string its own method for the job: padStart.
Why it fits here: padStart is the method this topic reads through its syntax line. One method in the language now does what a whole package once did.
Sources: The Register: How one developer just broke Node, Babel and thousands of projects in 11 lines of JavaScript; Wikipedia: ECMAScript version history
Why counting starts at zero
On 11 August 1982 the Dutch computer scientist Edsger Dijkstra wrote a short note called Why numbering should start at zero. He compared four ways of writing a range of numbers and argued for one of them. Then he drew his conclusion: an element's number should equal the number of elements before it. The first one has nothing before it, so it is number 0. He called zero a most natural number.
Why it fits here: This is the reason at(index) and most other methods count from 0: the first character has no characters before it.
Sources: E. W. Dijkstra Archive: Why numbering should start at zero (EWD831); Wikiquote: Edsger W. Dijkstra
In one line
A syntax line names a method's parameters in order, and a separate line without one means it is optional; fill them with arguments in that order, and check what type comes back.
Learning a new method in five minutes
At a glance
A new method can be learned in about five minutes with the same routine every time. Find its page and read four parts: the name, Syntax, Parameters and Return value. Run its Try it example. Then test three cases, and write one line of notes in your own words.
The three tests do the real work. An ordinary case shows the method doing its job. An edge case tries the limits, such as an empty string, zero or a negative index. A wrong case shows what happens when the method is misused: an error, undefined or a strange quiet value. When a run disagrees with the page, the reading is usually at fault, and the version comes next.
Take a guess: When a test disagrees with the docs, which is wrong more often: the page, or the way it was read?
A cook who finds a new spice in the market does not read a book about it. She tastes a pinch, adds a little to one dish, notices what it does, and remembers. The same short routine works for every new method you meet, and it takes about five minutes.
| Step | What you do | Time |
|---|---|---|
| 1. Find the page | search MDN with the method's name | 30 seconds |
| 2. Read four parts | the name, Syntax, Parameters, Return value | 1 minute |
| 3. Run Try it | copy the first example and run it | 30 seconds |
| 4. Test three cases | an ordinary case, an edge case, a wrong case | 2 minutes |
| 5. Write one line | what it does, in your own words, in a notes file | 1 minute |
Step 4 is where the learning happens. The ordinary case shows the method doing its job. The edge case tries the limits: an empty string, zero, a negative index. The wrong case shows what happens when you misuse it: an error, undefined or a quiet strange value. Knowing that third answer in advance saves an hour of debugging later.
Worked example 5
Learn trim in five minutes. MDN's page for String.prototype.trim() says: it removes whitespace (spaces, tabs, line breaks) from both ends of a string and returns a new string, without changing the original.
What we have: the page's four parts: syntax trim(), no parameters, returns a new string
What we need: three tests and a note
The plan: an ordinary case, an edge case and a wrong case, each printed with a label
const typed = " Asha ";
console.log("ordinary:", "[" + typed.trim() + "]");
console.log("edge, all spaces:", "[" + " ".trim() + "]");
console.log("the original is unchanged:", "[" + typed + "]");
console.log("wrong, on a number:", typeof (42).trim);
ordinary: [Asha]
edge, all spaces: []
the original is unchanged: [ Asha ]
wrong, on a number: undefined
- The brackets around each result show exactly where the spaces start and stop.
- The edge case: a string of spaces trims to an empty string.
- The original keeps its spaces: trim returns a new string, as the page said.
- Numbers have no trim job, so
(42).trimis undefined; calling it would be a TypeError.
Note: trim() returns a copy of the text without spaces at either end; the original is unchanged; only strings have it.
Check: every claim of the page was tested, and the note is in plain words.
Worked example 6
Learn includes, and find out whether it cares about capital letters. MDN: includes(searchString) returns true if the search string is found anywhere in the string, otherwise false.
What we have: the syntax line and the return value: a boolean
What we need: an answer to the capitals question, by test
The plan: test a match, a capital-letter version of the match, and an empty search
console.log("Pune".includes("un"));
console.log("Pune".includes("UN"));
console.log("Pune".includes(""));
true
false
true
- A match gives true. The same letters in capitals give false: includes is case-sensitive. The empty string is found in every string, an edge case worth knowing.
includes is case-sensitive: "UN" is not found in Pune.
Check: MDN's Description says the same: the search is case-sensitive.
When the page and your run disagree
Now and then a test prints something the page did not lead you to expect. There are four usual reasons, from the most common to the rarest.
| Reason | How to tell | What to do |
|---|---|---|
| You misread the page | read the Parameters and Description parts again, slowly | fix your test; this is the reason nine times out of ten |
| A different version | the method is newer than your browser or Node | check the page's Browser compatibility table; update, or use an older method |
| A different thing with the same name | you read the page for one kind of value and used another | check the name at the top: String.prototype.includes and Array.prototype.includes are two pages |
| The page is wrong | rare: the specification and other sources say otherwise | MDN pages have a link to report a problem; the community fixes them |
Worked example 7
A tutorial from 2016 says that to get the last character of a string you write word[word.length - 1]. A newer page uses word.at(-1). Do they agree?
What we have: two ways to read the last character, from two ages of the language
What we need: whether both give the same result
The plan: test both on the same word, and check when the newer one arrived
const word = "chai";
console.log(word[word.length - 1], word.at(-1));
i i
- Both give i. The square brackets read a character by its index, counting from 0, so the last index is the length minus 1.
- MDN's compatibility table for at() shows it arrived in browsers in 2021 and 2022, and it is part of ECMAScript 2022. An old tutorial could not know about it.
They agree: both print i. at(-1) is the newer, shorter way.
Check: the run shows the same result for both, so neither page was wrong; one was older.
Another way: when you write code for very old browsers, the older form works everywhere; for anything current, at(-1) reads better.
When you are stuck: a method you have never seen
Run the five-minute routine: page, four parts, Try it, three tests, one line of notes.
If the result surprises you, check in this order: did I misread; is my version too old; is this the page for the right kind of value.
Keep your notes in one file. After a month it is your own reference, in your own words.
Your turn
What are the three test cases of step 4?Tap to reveal
- One shows the job, one tries the limits, one misuses it.
An ordinary case, an edge case and a wrong case.
console.log("Asha Stores".includes("stores"), "Asha Stores".includes("Stores"));
What does this print? Say your answer aloud first, then press Run or tap to reveal.Tap to reveal
false true
- includes is case-sensitive.
- stores with a small s is not in the text; Stores is.
It prints false true.
Your test of a method throws is not a function, but its MDN page lists it. Name two possible reasons.Tap to reveal
- Check the version, and check which kind of value the page is for.
Your browser or Node is older than the method, or the page is for another kind of value (an array method used on a string, for example).
Did you know?
27 genes renamed because of a spreadsheet
Scientists keep lists of genes in spreadsheets, and Microsoft Excel kept reading some gene symbols, such as MARCH1 and SEPT1, as dates. By August 2020 the HGNC, the committee in charge of gene names, had renamed some 27 human genes to stop it: MARCH1 became MARCHF1 and SEPT1 became SEPTIN1. Even so, a 2021 report in Nature said that 30% of published papers still had mangled gene names in their extra data.
Why it fits here: Excel's guess works on ordinary text and fails on an edge case: text that looks like a date. Trying the edge cases of a tool shows such surprises early.
Sources: The Verge: Scientists rename human genes to stop Microsoft Excel from misreading them as dates; Nature: Autocorrect errors in Excel still creating genomics headache
A hammer, a feather and the Moon
At the end of the last Moon walk of Apollo 15, Commander David Scott tested an old idea live on television. He held out a hammer and a feather and let go of both at the same time. On the Moon there is almost no air to slow a feather down, so the two fell at the same rate, as Galileo had concluded hundreds of years before. A claim from the books was checked with one small experiment.
Why it fits here: It is this topic's routine on a grand scale: read a claim, then run a small test that shows whether it holds.
In one line
Learn a method in five minutes: find its page, read four parts, run Try it, test an ordinary, an edge and a wrong case, and write one line of notes. If a run disagrees, suspect your reading first, then the version.
Version numbers, and which version to use
At a glance
A version number, such as 22.23.1, says exactly which release of a tool is in use. Most tools follow semantic versioning: three numbers, MAJOR.MINOR.PATCH. The major number goes up when a change can break old code, the minor one when something new is added, and the patch number when only bugs are fixed.
Node brings out a new major version every six months. Each one starts as Current, for trying new features. Long-term support versions, called LTS, get fixes for years. A version past its support is end-of-life: it gets no fixes at all, not even for security holes. The language has editions too, called ECMAScript, one a year since 2015.
Take a guess: A program needs Node 24 or later, and the laptop runs Node 22: will it run?
A school textbook has editions. A reprint fixes a few typing errors; a new edition may add a chapter; a new syllabus can change the book so much that old notes no longer match. You would want to know which of these you are holding before you study from it. Software is the same, and its version number tells you.
A label such as 22.23.1 that says exactly which release of a tool you have. Most tools follow semantic versioning: three numbers, MAJOR.MINOR.PATCH, each with a meaning.
| Part | In 22.23.1 | It goes up when | In the textbook picture |
|---|---|---|---|
| MAJOR | 22 | something changed that can break code written for the old version | a new syllabus |
| MINOR | 23 | something new was added, and old code still works | a new chapter added |
| PATCH | 1 | only bugs were fixed | a reprint with corrections |
So going from 22.23.1 to 22.23.4 should be safe: only fixes. Going from 22 to 24 may break things, and a careful developer reads the release notes first. When a number goes up, the numbers after it go back to 0: after 22.23.4 comes 22.24.0, and after that, one day, 23.0.0.
Which Node am I running?
Type node --version in a terminal, or ask Node from inside a program. Node keeps its version in process.version (process is Node's own record of the running program; a browser has no such thing).
version.js
console.log("Node version:", process.version);
Terminal
/home/asha/shop$ node version.js
Node version: v22.23.1
This is the Node that ran every code block of this school's lessons, and the reason each lesson's page says it was checked against Node 22.23.1.
Node's release lines
A new major version of Node comes out every six months. It starts as Current: the newest features, for trying out. Up to Node 26, the even-numbered versions then became LTS, long-term support, with critical fixes for about 30 months in all; the odd-numbered ones were dropped after six months. From Node 27 the cycle becomes yearly, and every major version becomes LTS. A version past its support is end-of-life, EOL: it gets no more fixes, not even for security holes.
| Version | Name | Status on 26 October 2026 | Latest release |
|---|---|---|---|
| Node 26 | Current | 26.12.1 | |
| Node 24 | Krypton | LTS | 24.22.1 |
| Node 22 | Jod | LTS | 22.23.4 |
| Node 20 | Iron | end-of-life | 20.20.2 |
The table comes from nodejs.org's page of releases, read on the date shown. It changes every few weeks, so for a real decision, read the page itself. Notice that this laptop's Node, 22.23.1, is behind its own line's latest, 22.23.4: three patch releases of fixes it does not have yet.
Which Node to use
For anything real, an LTS version, and the latest patch of it. Current is for trying new features. Never an end-of-life version for anything on the internet: its security holes stay open.
JavaScript's own versions
The language itself has editions too, set by a committee called TC39 and published as the ECMAScript standard. Since 2015 there has been one edition a year, named after its year. Most editions add a few features; old code keeps working, because the web cannot afford to break old pages.
| Edition | Some features it added | Met in |
|---|---|---|
| ECMAScript 2015 | let, const, includes for strings | lessons 1 and 4 |
| ECMAScript 2017 | padStart, padEnd | this lesson |
| ECMAScript 2021 | replaceAll | this lesson |
| ECMAScript 2022 | at | this lesson |
console.log("9-15-30".replaceAll("-", ":"));
9:15:30
Worked example 8
A project's notes say it needs "Node 24 or later". Your laptop has Node 22.23.1. Can you run it?
What we have: the requirement, and your version
What we need: an answer, with the reason
The plan: compare the major numbers first; they decide
- The requirement's major is 24; yours is 22.
- 22 is less than 24, so your Node is older than the project allows.
- The project may use features that arrived in Node 23 or 24, and those would fail with errors such as is not a function.
No: install an LTS version of Node 24 or later first.
Check: only the major numbers mattered here; the 23 and the 1 cannot make 22 count as 24.
Worked example 9
Read the version 3.14.2 and say what kind of change each of these next versions would be: 3.14.3, 3.15.0, 4.0.0.
What we have: a version and three possible next versions
What we need: what each would contain
The plan: find which part went up
- 3.14.3: the patch went up: bug fixes only.
- 3.15.0: the minor went up, and the patch went back to 0: new features, old code still works.
- 4.0.0: the major went up: changes that may break code written for version 3.
3.14.3 is fixes, 3.15.0 adds features, 4.0.0 may break things.
Check: in each new version, every part after the one that went up is back to 0, as the rule says.
When you are stuck: which version you have, or which you need
Run node --version in a terminal, or print process.version in a Node file.
Compare the major numbers first: they decide whether code is likely to work.
For a real project, choose the latest patch of an LTS version, from nodejs.org's releases page.
Your turn
In 24.22.1, which number is the minor, and what does it mean when it goes up?Tap to reveal
- The three parts are major, minor, patch.
22; new features were added and old code still works.
Why should a website never run on an end-of-life version of Node?Tap to reveal
- End-of-life means no more fixes.
Because security holes found after its end are never fixed.
console.log("a-b-c".replaceAll("-", ""), "a-b-c".replaceAll("-", " "));
What does this print? Say your answer aloud first, then press Run or tap to reveal.Tap to reveal
abc a b c
- replaceAll swaps every - for the second argument.
- An empty string removes them; a space puts a space in each place.
It prints abc a b c.
Did you know?
There is no ECMAScript 4
JavaScript's standard is called ECMAScript, and its editions are numbered. The 3rd edition came out in December 1999 and the 5th in December 2009. There is no 4th. For over a year the committee was split between a large 4th edition and a smaller update of the 3rd. Brendan Eich, the creator of JavaScript, then announced a plan more modest than the 4th edition, and the 4th was abandoned. Some of its ideas came back years later, in the 6th edition.
Why it fits here: Version numbers do not always run one after another. Reading the real numbers, and never assuming them, is the habit this topic teaches.
Sources: Wikipedia: ECMAScript version history; Brendan Eich on es-discuss: ECMAScript Harmony; Brendan Eich: New JavaScript Engine Module Owner
Node went from 0.12 straight to 4
In December 2014 a developer, Fedor Indutny, started a copy of Node called io.js, as an alternative with a more open way of running the project. For a while there were two versions of Node's code, and io.js reached version 3 while Node was still at 0.12. In September 2015 the two were joined again, and the combined release was called Node 4.0. So Node never had a version 1, 2 or 3 of its own.
Why it fits here: A jump in a version number has a story, and the release notes tell it. A careful developer reads them before moving to a new major version.
Sources: Wikipedia: Node.js; Node.js blog: Node v4.0.0
The rules of a version have an author
The meaning of MAJOR.MINOR.PATCH did not grow up by chance. It is set out in a short specification called Semantic Versioning, SemVer for short, which anyone can read at semver.org. Its first author was Tom Preston-Werner, who also invented Gravatar and co-founded GitHub.
Why it fits here: Because the rules are written down for everyone, a version number can mean the same thing whichever tool it belongs to.
In one line
A version is MAJOR.MINOR.PATCH: breaking changes, new features, fixes. Use the latest patch of an LTS Node for real work, never an end-of-life one, and check versions whenever docs and a run disagree.
Will it work in every browser?
At a glance
A feature can be part of JavaScript and still fail in a visitor's browser, because new features arrive with browser updates. MDN answers the question on most pages with a Baseline label, judged on a fixed set of browsers: Chrome, Edge, Firefox and Safari. Widely available means it has worked in all of them for at least 2.5 years. Newly available means it works in their latest versions, and Limited availability means it is not yet in all of them.
For an exact answer, a Browser compatibility table at the bottom of the page lists the first version of each browser that supports the feature. A program can also check by itself: typeof gives undefined for a job that does not exist.
Take a guess: A feature works in your own Chrome: does that mean it works for every visitor?
A new UPI feature reaches your phone only when your bank's app is updated. Until then, a friend can use it and you cannot, although you both have UPI. New JavaScript features reach people the same way: through browser updates. A feature can be part of the language and still not work for a visitor whose browser is old.
For a page that only you will open in your own Chrome, this rarely matters. For a website that thousands of people visit on all kinds of phones, it matters a lot. MDN answers the question on every page, in two places.
The Baseline label
Near the top of most MDN pages is a Baseline label. It looks at a fixed set of browsers, the core browser set: Chrome on desktop and Android, Edge on desktop, Firefox on desktop and Android, and Safari on macOS and iOS.
| Label | What it means, in MDN's words | Should you use it? |
|---|---|---|
| Widely available | a consistent history of support in each of the Baseline browsers for at least 2.5 years | yes, for any audience |
| Newly available | works in at least the latest stable version of each Baseline browser, but may not work with older browsers and devices | yes, if your visitors keep their browsers up to date; check first for a wide audience |
| Limited availability | not yet available in all browsers | only with a fallback, or only where you know the browser |
toFixed is Widely available: it has worked across browsers since July 2015. Everything taught in these first lessons is too. You will meet Newly available and Limited availability features later, in the web and browser extension tracks.
The compatibility table
At the bottom of each page, Browser compatibility is a table with one column per browser and the first version that supported the feature. A second part of the table covers servers, with Node.js among them. A green box with a version number means supported from that version on; a red box means not supported; a note marks partial support. When the Baseline label is not enough, for example because you must support one particular old phone, this table answers the question exactly.
Checking in code
A program can also check for a feature itself before using it. A job that does not exist is undefined, as lesson 2 showed. So typeof tells you whether it is there.
console.log(typeof "chai".at, typeof "chai".shout);
function undefined
at exists, so its type is function. shout does not, so it is undefined. A careful program uses the newer job only if it exists, and an older way otherwise. Writing that choice needs the word if, which the JavaScript step teaches; the check itself is this one line.
Worked example 10
You want to use replaceAll on a website for a school whose computer room has very old browsers. How do you decide?
What we have: MDN's page for replaceAll, and the school's old browsers
What we need: a decision, with a reason
The plan: read the Baseline label, then the compatibility table for the oldest browser you must support
- The label is Widely available: it has worked in all core browsers for at least 2.5 years.
- But the school's browsers are older than that. The compatibility table shows the first version of each browser that has replaceAll: Chrome, Firefox and Safari all added it in 2020.
- Any browser older than those will throw is not a function.
- An older job does the same work, written another way; or the school can update its browsers.
Check the oldest browser against the compatibility table: if it is older than the first supporting version, do not rely on replaceAll there.
Check: the table, not the label, decides for one particular old browser; the label is a summary for most visitors.
Worked example 11
Test whether this browser, the one you are reading in, has the jobs used in this lesson.
What we have: the browser you are using now
What we need: a list of which jobs exist
The plan: print the typeof of each job; function means it exists
const s = "test";
console.log("at:", typeof s.at);
console.log("padStart:", typeof s.padStart);
console.log("replaceAll:", typeof s.replaceAll);
console.log("trim:", typeof s.trim);
at: function
padStart: function
replaceAll: function
trim: function
In any up-to-date browser, all four print function.
Check: the output shown was produced by Chrome's engine and by Node; press Run to see your own browser's answer.
When you are stuck: whether a feature is safe to use
Read the Baseline label first. Widely available is safe for almost everyone.
For a particular old browser or device, read the compatibility table at the bottom of the page.
In code, typeof value.job is function when the job exists.
Your turn
What does Baseline Widely available promise?Tap to reveal
- MDN's words: a consistent history of support in each of the Baseline browsers for at least 2.5 years.
That the feature has worked in every core browser for at least 2.5 years.
console.log(typeof "x".padEnd, typeof "x".toTitleCase);
What does this print? Say your answer aloud first, then press Run or tap to reveal.Tap to reveal
function undefined
- padEnd is a real job of strings.
- toTitleCase is not; a missing job is undefined.
It prints function undefined.
Where on an MDN page do you find the first browser version that supports a feature?Tap to reveal
- It is a table near the bottom.
In the Browser compatibility table.
Did you know?
Almost every browser says it is Mozilla
Each time a browser asks for a page, it sends a line that names itself, called the user agent. Almost every browser today begins that line with Mozilla, for historical reasons. Netscape's early browser called itself Mozilla and could show frames, so websites sent frames only to browsers named Mozilla. Internet Explorer could show frames too, so it began to call itself Mozilla compatible, and the browsers after it copied the trick.
Why it fits here: Telling browsers apart by their names went so badly that the names stopped meaning much. Checking for the feature itself, with typeof, is the reliable way.
Sources: MDN: User-Agent header; WebAIM: History of the browser user-agent string
The browser that once had 95% of the web
Internet Explorer, Microsoft's browser, won the first browser war against Netscape and became the most widely used browser of all, with about 95% of use by 2003. Microsoft later released Edge to succeed it. Support for Internet Explorer 11 officially ended on 15 June 2022, when Microsoft announced that it had retired.
Why it fits here: A browser can stay in use long after the language moves on, and the compatibility table is how a developer knows which features such a browser lacks.
Sources: Wikipedia: Internet Explorer; Microsoft, Windows Experience Blog: Internet Explorer 11 has retired and is officially out of support
In one line
Baseline tells you at a glance whether a feature works across browsers (Widely available is safe for almost everyone); the compatibility table gives exact versions, and typeof checks for a job in code.
Where it is used
Looking things up is a daily part of every developer's work, at every level. Senior developers look things up more than beginners, not less, because they work with more tools.
| What you learned | Where it is used | A real example |
|---|---|---|
| reading a reference page | every new method, library or tool | a developer adding Indian rupee formatting finds toLocaleString on MDN and reads that the locale en-IN groups digits as 1,50,000 |
| syntax lines and parameters | every call to a job you have not used for a while | checking whether padStart takes the length or the pad string first, before writing a receipt printer |
| the five-minute routine | learning a library in a new job | a team adopts a date library; each developer spends ten minutes testing its main jobs before using them in real code |
| semantic versioning | every update of every package | a tool goes from 3.2.0 to 4.0.0; the team reads its release notes for breaking changes before updating |
| Node's LTS lines | choosing what runs a server | a company keeps its servers on Node 24 LTS and plans the move to the next LTS months ahead of Node 24's end of support |
| end-of-life | security reviews | an audit flags a server still on Node 20, end-of-life, as a risk to fix at once |
| Baseline and compatibility tables | every public website | a bank's site avoids a Newly available feature until its oldest supported phones have it |
| typeof checks for a job | code that runs on many browsers or Node versions | a library uses the newer, faster job where it exists and an older one elsewhere |
Mistakes and debugging
These are the mistakes people make with documentation and versions, and the fix for each.
1. Reading a page for the wrong kind of value
String.prototype.includes and Array.prototype.includes are two different pages for two different jobs with the same name. The fix: read the full name at the top of the page; the word before .prototype says which values have the job.
2. Trusting a result's type without checking
const price = (5.6).toFixed(1);
console.log(price + 1);
5.61
toFixed returns a string, so + joins. The page said so under Return value. The fix: read Return value every time, and use Number(...) before doing more sums: Number(price) + 1 is 6.6.
3. Swapping arguments
console.log("9".padStart("0", 2) + "|");
9|
No error and no padding: the length and the pad string are in each other's slots. The fix: follow the syntax line's order, padStart(targetLength, padString).
4. Counting from 1 where code counts from 0
console.log("Pune".at(1));
u
If you expected P, you counted from 1. The fix: index 0 is the first character.
5. Following a page for another version
A blog post written for Node 18 may use a job that Node 24 has since removed, or miss one that Node 22 added. The fix: check the date of what you read, check your own version, and prefer the official docs for your version.
6. Staying on an old version for years
Old versions keep working, so it is easy to forget them, until a security hole is found and no fix comes. The fix: note your Node version and its end-of-support date, and plan to move to the next LTS before that date.
The debugging corner: is it the version?
When code works on one machine and fails on another, print the version on both first: node --version in a terminal. A different major version is the cause surprisingly often, and it takes ten seconds to check.
Quick card
The lesson on one card.
| On an MDN page | Read it for |
|---|---|
| the name (Type.prototype.job) | which values have the job |
| Syntax | how to write the call; a line without a parameter means it is optional |
| Parameters | what each argument means, and its limits |
| Return value | what comes back, and its type |
| Exceptions | the errors it can throw |
| Baseline label | Widely available, Newly available or Limited availability |
| Browser compatibility | the first version of each browser, and Node, that has it |
The jobs in code
// the jobs met in this lesson
console.log((5.6).toFixed(), "42".padStart(5, "0"), "Rice".padEnd(6, ".") + "|");
console.log("chai".at(-1), " Asha ".trim(), "Pune".includes("un"));
console.log("9-15".replaceAll("-", ":"), "9876543210".slice(-4));
// money in Indian digit groups
console.log((150000).toLocaleString("en-IN"), (1234567).toLocaleString("en-IN"));
6 00042 Rice..|
i Asha true
9:15 3210
1,50,000 12,34,567
| Version part | Goes up for |
|---|---|
| MAJOR (22.x.x) | changes that can break old code |
| MINOR (x.23.x) | new features; old code still works |
| PATCH (x.x.1) | bug fixes only |
Which Node: the latest patch of an LTS version for real work; Current to try new features; never end-of-life. When a run disagrees with a page: your reading, your version, the kind of value, then (rarely) the page.
The story: The plate on the base
The answer is on the lamp itself. A small brass plate on its base gives its make and its number: series 4. The blue manual is for series 4. The green one is for series 2, from years ago.
You open the blue manual, find the command, and read every part it takes, in order. The lamp lights at the first try.
Corin looks at his copied page. "So the green book was right," he says, "for some other lamp." "Every manual is right for its own version," says the archivist, and puts the green one back on its shelf.
Reagents gathered: documentation, parameter, version number.
Sources
- MDN Web Docs (Prose CC BY-SA 2.5 or later; code samples added since 2010-08-20 CC0 (its licensing page, read 2026-10-26); reused with credit)
- The Node.js documentation (Not stated for the docs in the Node.js LICENSE file (read 2026-10-26); facts and ideas only)
- The ECMAScript language specification (ECMA-262) (Ecma International copyright; facts and ideas only)