JavaScript: A Practical Guide
JavaScript is the language the web runs on, and the one nearly every modern stack drops you back into sooner or later. React components, browser events, build scripts, and a lot of AI-generated code all sit on the same runtime rules. Hide those rules behind a framework and they are still there, waiting to explain your bug.
If you already know what you want to learn, skip to the list of JavaScript guides.
JavaScript at a Glance
The live part of this section splits into four topics. The first is the language itself, and the other three are the places it runs into trouble.
- Language Basics
- Covers Values, functions, objects, modules
- Start here if The syntax itself is still new
- Node
- Covers The terminal, running files, npm, scripts
- Start here if You want to run code outside a browser
What Is JavaScript, in Plain Words?
JavaScript is a programming language that describes values and the work done on them. MDN, the web's reference library, calls it a lightweight interpreted language with first-class functions, which just means you can hand a piece of work around like any other value.
A value is a piece of data: a number, a string, or an object holding named fields. A function is a named piece of work you can hand values to. An object is a bag of named values, and an array is an ordered one. Almost everything else in the language is a way of arranging those three things.
The language is also loose on purpose. Nothing declares the shape of a cart item, and nothing checks it before the code runs. That looseness is why you can wire up a form in ten minutes, and it is also why a missing property, a late response, or a stale listener can reach production without anything complaining first.
One more name will come up as you read around the web. ECMAScript is the standard that defines the language, and engines such as V8, SpiderMonkey, and JavaScriptCore implement it in your browser or runtime.
What Is JavaScript Used for Beyond the Browser?
The browser is the home turf for this language. JavaScript reads user input, responds to events, updates the page, calls APIs, and holds small pieces of client state, so any frontend work goes through it. MDN adds that many non-browser environments use it too, such as Node.js, Apache CouchDB, and Adobe Acrobat.
Outside the browser, the host changes and the language stays familiar.
| Where it runs | What gets built | Where to learn it |
|---|---|---|
| Browser | Interactive pages, forms, front ends | DOM topic |
| Node on a server | APIs and network applications | Node topic |
| Node on your machine | Scripts, automations, command-line tools | Small automations |
| Desktop apps | Desktop clients such as Slack's | Language basics |
| Build tooling | Bundlers, test runners, code generators | package.json and scripts |
| Edge runtimes | Small request handlers near users | Async topic |
Slack's engineering blog is a good example of the desktop row. Its 2017 post describes the Slack desktop app as a JavaScript-based application, and explains why the team ported it to TypeScript. Node's own site describes the runtime as asynchronous and event-driven, designed to build scalable network applications.
Even if you end up preferring TypeScript for serious application work, the JavaScript underneath still matters. Type annotations are erased before the code runs, so closures, promises, modules, objects, and browser APIs behave exactly as this section describes.
Who Uses JavaScript, and Is It Still Growing?
It is still the most widely used language in the biggest developer survey. In the 2025 Stack Overflow Developer Survey, 66% of all respondents and 68.8% of professional developers said they used JavaScript. Among people learning to code, the figure was 62.8%.
Node.js came in at 48.7% in the same survey, ahead of React at 44.7%, and Next.js and Express sat near 20%. Python ranked fourth overall at 57.9%, and TypeScript sixth at 43.6%.
GitHub's Octoverse report for 2025 adds the growth picture. JavaScript gained 427,000 contributors that year, up 24.79%, yet TypeScript grew much faster and took the top spot. GitHub also says the JavaScript and TypeScript ecosystem still accounts for more overall activity than Python alone. The two languages share one runtime, so one's rise costs the other nothing.
Read those numbers as popularity and not as job offers. A language alone will not land you a role, and results vary a lot by market.
Where Did JavaScript Come From?
Early web pages were static HTML, and nothing could change a page after it loaded. JavaScript was added to the Netscape browser in 1995 so a page could run code on the visitor's machine.
The language was standardized as ECMAScript, and ES2015 added the syntax most current code uses.
Node later took the same language onto servers and tooling. That history matters for one practical reason. Search results do not sort themselves by age, so you will keep meeting advice written for a different era. The next section sorts the old from the new.
Why Does Old JavaScript Advice Look Wrong?
JavaScript has more outdated writing about it than almost any other language. Four relics show up most often, and knowing why saves you from copying a workaround for a problem you no longer have.
- Answers built on
var: older code declares variables in a way that ignores block scope, andletandconstremoved the puzzle, as the values and equality guide covers. - Callbacks nested into a pyramid: before promises, every step that had to wait went inside the previous one, and promises and async/await is where the flat modern shape is taught.
- jQuery for things the browser now does:
querySelector,classList, andfetchare built in, and selecting elements and updating the page shows the equivalents. - Module advice from before Node could detect ESM: current Node versions can spot ESM syntax in an ambiguous file, while explicit markers still matter, a boundary modules, imports, and exports walks through.
Is JavaScript Still Worth Learning with AI Agents Writing Code?
Yes. Agents will happily draft the page, the form handler, and the fetch call, and then you are the one who has to say whether the result is any good. In the 2025 Stack Overflow survey, 84% of respondents were using or planning to use AI tools, while 46% distrust the accuracy of what those tools produce and only 33% trust it. The top frustration, cited by 66%, was answers that are almost right but not quite.
Almost right is the exact shape of a JavaScript bug. An agent will write a listener that is never removed, a request whose stale answer lands after the fresh one, or a closure that captures the wrong counter. Each of those runs fine in a demo and fails later, so you only catch them if you know the language rules underneath.
| Agent habit | What to check | Guide |
|---|---|---|
| Fetch with no status check | Error responses treated as success | Fetch and JSON |
| Overlapping requests | Stale answers overwriting fresh ones | Races and timers |
| Listeners added on every render | Leaks that grow with use | Listener cleanup |
| Copying an object by assignment | Two names, one shared object | Objects and arrays |
Tools change fast and results vary by project, but my call stays the same. Learn enough JavaScript to read what comes back, then let the assistant do the typing. For the job-market argument, our should you learn to code article has the survey data, and the vibe coding hub covers building with prompts alone.
Should I Learn JavaScript or Python First?
Start from what you want to build. If your goal has a screen on it, learn JavaScript, because it is the only language that runs natively in a browser. If your goal has a spreadsheet or a model on it, learn Python. If you just want to learn to code and cannot say more than that, my lean is Python for the gentler first week, then JavaScript the moment you want to build something people can click.
| Question | JavaScript | Python |
|---|---|---|
| First week project | A page that reacts to clicks | A script that renames files |
| Where it runs | Every browser, plus Node | Servers and your machine |
| Setup | Browser console, nothing to install | Install Python, use a terminal |
| Strongest at | Web interfaces and full-stack apps | Data, scripting, AI work |
| Learners using it | 62.8% in 2025 | 71.8% in 2025 |
The last row comes from the Stack Overflow survey's learner numbers, and it only tells you what people picked, which is a different question from what is best for you. Both are fine first languages, and most of what you learn transfers.
Should I Learn Frontend or Backend JavaScript?
It is the same language in two different hosts, so you do not have to choose forever. Pick the one that matches the thing you want to see working first.
| Question | Frontend | Backend |
|---|---|---|
| Where the code runs | In the visitor's browser | On a server or your machine |
| What you wrangle | Elements, clicks, forms | Files, requests, packages |
| What you see first | A page changing in front of you | Text printed in a terminal |
| Learn it in | The DOM topic | The Node topic |
If you want to see results fast, go frontend, and read the frontend development hub for the order to learn HTML, CSS, and JavaScript. If your goal is automating chores or building an API, start with Node. The backend development hub also covers server languages other than JavaScript, such as Python, Go, and PHP.
Node, Deno, or Bun?
All three run JavaScript outside a browser, and all three will run your first script. Node is the long-standing choice and the one this section teaches. Deno and Bun are newer runtimes with different bets about what should come built in.
| Runtime | Its own pitch | Pick it when |
|---|---|---|
| Node | Asynchronous, event-driven runtime for network apps | You are learning or following guides |
| Deno | Secure by default, runs .ts files directly | You want permissions and built-in tools |
| Bun | All-in-one toolkit built on JavaScriptCore | One tool for runtime, installs, tests |
Usage tells you where the guides and the hosting support are. In the 2025 survey Node.js was used by 48.7% of respondents, Bun by 5.5%, and Deno by 4%. Deno says its code runs in a sandbox with no file, network, or environment access until you grant it. Bun says it aims for full compatibility with Node's built-in modules, and calls that an ongoing effort.
One piece of news is worth knowing. In December 2025 Anthropic announced it was acquiring Bun, and said Bun will remain open source and MIT-licensed. My advice for a beginner is still Node first, since every tutorial and error message you will search for assumes it.
Why Does JavaScript Run One Thing at a Time?
Your page or script is one agent, which means a single thread with its own queue, and one job runs to completion before the next job starts. Nothing interrupts a running function, whether it is a click, a timer, or a response from a server.
Think of a diner counter in North Jersey with exactly one short-order cook. Tickets pile up on the rail, and the cook never drops a half-finished plate to grab the next ticket. A timer set to zero seconds is a ticket that still waits until the current plate is done.
Work that has to wait is never done by waiting. You hand the job to the host around your code, either the browser or Node, and it hands you back a callback or a promise when the work finishes. The host drains waiting promise callbacks first and then takes one more piece of queued work, and a browser is free to repaint in between. That repeating cycle is the event loop, and Node organizes its own turns a little differently.
Three consequences run through the rest of this section. Slow synchronous work blocks everything, including clicks and typing in a browser, which is why async work exists at all. Callbacks run later than the code around them, which is why closures matter so much in practice. And queued work has an order of its own, which timers, ordering, and race conditions works through case by case.
How Do I Run JavaScript Code?
There are two places, and which one you pick depends on what you are learning rather than on your level.
In a browser, right-click any page, choose Inspect, open the Console tab, and paste the code straight in. That is the right home for anything touching a page, like elements, clicks, and forms.
For a file you can save and re-run, install Node and run node app.js from a terminal. That is the right home for language practice and for anything with no page involved. The Node topic starts with the terminal itself if that part is the obstacle.
What Can't JavaScript Do?
It cannot type-check your work before it runs. The engine rejects broken syntax, but nothing built in catches a misspelled property name until that line executes, which is the gap TypeScript and other static analysis tools exist to fill.
It cannot keep a secret in the browser. Anything shipped to a page can be read, so API keys, pricing rules, and permission checks belong on a server, a position application security starts from.
It cannot reach past what its host allows. A browser page cannot silently pick files off the machine, since the file APIs need the person to choose or grant them, and Node has different limits, which is exactly why the same code does not run in both places.
And one agent cannot do two things at once. Running JavaScript in parallel means a second agent, either a web worker in the browser or a worker thread in Node, and those agents can share memory rather than variables.
Where Do I Go Next? Every Guide Under This Page
Each group starts from the problem you are probably having, then lists the guides that fix it in reading order.
Language Basics
Start here if the language keeps surprising you: two values that look equal are not, or a copied object changes in two places. The language basics topic holds the four guides together.
- Values, Variables, and Equality:
letandconst, the primitive types, why==converts before comparing, and what counts as falsy. - Functions, Callbacks, and Closures: declarations against expressions, arrow functions and
this, callbacks, and the live variables a closure keeps hold of. - Objects, Arrays, and Destructuring: property access,
mapandfilterandreduce, spread and rest, and the difference between copying and sharing. - Modules, Imports, and Exports: named and default exports, import paths, the ESM and CommonJS boundary, and script loading order.
Async
Start here if everything worked until you added a request, and now results arrive in the wrong order. All three guides sit under the async topic.
- Promises and async/await: the three states a promise can be in, chaining,
await, waiting on overlapping work, and where errors surface. - Fetch, JSON, and the Network: reading a response,
response.ok, sending a POST, telling a bad answer from no usable answer, and cancelling withAbortController. - Timers, Ordering, and Race Conditions:
setTimeoutandsetInterval, what runs first, the stale-response bug, and debouncing typed input.
The DOM
Start here if a button stops working on the second click, or a page gets heavier the longer someone uses it. The DOM topic covers how the three guides connect.
- Selecting Elements and Updating the Page:
querySelector,textContentagainstinnerHTML, classes, data attributes, and building nodes. - Events, Forms, and User Input:
addEventListener, the event object,preventDefault, delegation, and submitting a form withFormData. - Listener Cleanup and Page Lifecycle: removing listeners,
AbortControlleron events, when a script is allowed to run, and why leaks outlive a rewrite.
Node
Start here if the code is fine and still refuses to run: the terminal is unfamiliar, or a command is not found. The Node topic begins with the terminal itself.
- Running JavaScript with Node: installing and checking versions, running a file, arguments, printed output, and exit codes.
- package.json, npm, and Scripts: the fields that matter, dependencies against devDependencies, npm scripts, and what a lockfile is for.
- Files, Environment Variables, and Small Automations: reading and writing files, paths, environment variables, and one bulk-edit script worth stealing.
What Should I Learn First?
Learn it in roughly the order that makes real code less mysterious.
- Start with language basics: values, equality, functions, closures, objects, arrays, and modules.
- Move to async once ordinary code is boring: promises,
await, fetch, and the failures each one has. - Add the DOM when you want a real page to respond to a real person.
- Pick up Node whenever you need to run something outside a browser, which is often sooner than people expect.
- Build one small project end to end before going near a framework.
- Add TypeScript when a project grows contracts worth writing down.
The order of the middle three is yours to choose. Someone automating a spreadsheet should go to Node third and may never need the DOM, while someone fixing a marketing site should do the reverse. Only the first step is fixed, because the other three assume it.
What Should I Build First?
Build one small feature with real inputs and real failure paths. A newsletter form is enough if you treat it seriously: validate the field, call an API, handle a failed request, disable the button while it is in flight, show a result, and take the listeners off again if the form can disappear.
That one exercise touches values, closures, events, a promise, a fetch that can fail, and cleanup, which is most of what this section teaches. When it feels ordinary, a framework is the next step, and it will be a smaller step than it looks.
Which Languages and Comparisons Sit Next to JavaScript?
- JavaScript vs TypeScript: the full side-by-side, if you are weighing whether adding types is worth it yet.
- TypeScript: the same runtime with a type checker in front of it, for code that has outgrown being held in your head.
- HTML and CSS together: how the two other core web languages fit with JavaScript on a page.
- HTML: the document structure the DOM guides spend their time changing.
- CSS: styling, layout, and states, which is often the better tool for behavior you were about to script.
- Python: the stronger choice when data work and scripting matter more than running in a browser.
- Programming: the wider language index, including the data and database guides.
Frequently Asked Questions
Which topic should you start with?
Language basics, unless you already write JavaScript comfortably. Async is the topic most people are stuck in, but promises are hard to reason about before closures make sense. The DOM and Node topics are chosen by where your code runs rather than by order.
What is the difference between JavaScript and Java?
They are unrelated languages that share part of a name for historical marketing reasons. Java is a statically typed language that usually runs on the JVM; JavaScript is dynamically typed and runs in browsers and in runtimes such as Node.
What is the difference between JavaScript and ECMAScript?
ECMAScript is the standard that defines JavaScript, and engines such as V8, SpiderMonkey, and JavaScriptCore implement it. Names such as ES2015 refer to editions of that standard, while whether a feature works still depends on the browser or runtime version in front of you.
Do you need a framework to learn JavaScript?
No, and starting with one usually slows you down. The DOM, events, and asynchronous behavior are the foundation every framework sits on. Learn those first, then a framework makes sense because you can see what it is doing for you.
Do you need Node to learn JavaScript?
Not for browser work, where the console in your developer tools runs code immediately. Reach for Node once you want to run a file on your own machine, script outside a page, or use the tooling most projects are built with. Deno and Bun run JavaScript files too; this section teaches Node.
Is JavaScript single threaded?
One agent, meaning one page or one script, runs its jobs on a single thread and finishes each one before starting the next. Workers are separate agents with their own threads, and agents can share memory, so JavaScript as a whole can use more than one thread.
Should you learn TypeScript as well?
Eventually, once JavaScript itself stops being the confusing part. TypeScript checks the shapes your code expects, and its type-only syntax is erased before execution while a few constructs emit JavaScript. Either way, every runtime rule on this page still applies underneath it.
Should you learn JavaScript or Python first?
Pick by what you want to build. JavaScript is the only language that runs natively in a browser, so it wins for anything on the web, while Python is stronger for data, scripting, and automation. Both are reasonable first languages for a total beginner.
Is JavaScript still worth learning now that AI writes code?
Yes, it is still worth learning for most people. Assistants draft JavaScript quickly, and in the 2025 Stack Overflow survey the biggest frustration with AI output was answers that are almost right but not quite. Knowing the language is how you spot the stale response, the leaked listener, or the shared object before a user does.
Is JavaScript hard to learn?
The basics are approachable, and a browser console gives you feedback with nothing to install. The hard parts arrive later: equality rules, closures, and asynchronous code. Most beginners hit those within the first few weeks, which is normal and says nothing about your ability.
Where to Start
Open your browser console, paste in a one-line experiment, and see what happens today. Then work through language basics, and read the DOM guides alongside your first small build rather than before it.
Sources
-
[1]
JavaScript(developer.mozilla.org)
-
[2]
JavaScript Guide(developer.mozilla.org)
-
[3]
Modules(developer.mozilla.org)
-
[4]
Using Promises(developer.mozilla.org)
-
[5]
Using the Fetch API(developer.mozilla.org)
-
[6]
EventTarget: addEventListener()(developer.mozilla.org)
-
[7]
Node.js Documentation(nodejs.org)
-
[8]
Getting Started with Vite(vite.dev)
-
[9]
2025 Stack Overflow Developer Survey: Technology(survey.stackoverflow.co)
-
[10]
2025 Stack Overflow Developer Survey: AI(survey.stackoverflow.co)
- [11]
-
[12]
About Node.js(nodejs.org)
-
[13]
Deno documentation(docs.deno.com)
-
[14]
Bun documentation(bun.com)
-
[15]
Anthropic acquires Bun as Claude Code reaches $1B milestone(anthropic.com)
-
[16]
TypeScript at Slack(slack.engineering)
Read Next
Should you learn TypeScript or JavaScript first? What TypeScript is used for and who uses it, whether it is worth it with AI agents, running it in Node, and a roadmap to every guide.
JavaScript and TypeScript are the same language with one big difference: types. Here is what TypeScript actually adds, when the extra step pays off, and which one a beginner should start with.
A starting point for browser-side programming on CodeWalkers: the languages that run in the browser, and the frameworks built on top of them.