JavaScript Guide: Uses, Basics, and Where to Start
JavaScript is a programming language used to make web pages interactive and to build apps, servers, and automation scripts. 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 JavaScript guides. For other languages, see the programming hub.
JavaScript at a Glance
Start with language basics, then choose browser interactions, asynchronous work, or Node scripts according to what you want to build.
- Language Basics
- Covers: Values, functions, objects, modules
- Start here if: The syntax itself is still new
- Async
- Covers: Promises, await, fetch, timers, races
- Start here if: Results arrive in the wrong order
- DOM
- Covers: Selecting, updating, events, forms, cleanup
- Start here if: You are wiring up a real page
- Node
- Covers: The terminal, running files, npm, scripts
- Start here if: You want to run code outside a browser
What Is JavaScript?
JavaScript is a programming language that adds behavior to websites and runs applications outside the browser. HTML supplies a page’s structure, CSS controls its appearance, and JavaScript responds to actions such as clicks and form submissions.
A value is a piece of data: a number, a string, or an object holding named fields. A function is a reusable 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. Variables can hold different types of values, and ordinary objects can gain new properties. That flexibility makes quick experiments easy, but you still need tests and checks for missing or unexpected data.
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?
JavaScript can also run on a server or your computer. With Node.js, you can build an API, rename a folder of files, or run tools that prepare a website for publishing. Frameworks such as Electron let you build desktop apps with JavaScript, HTML, and CSS.
| 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 built its desktop app with JavaScript, then moved to TypeScript to catch more mistakes before they caused crashes, as its engineers explained in 2017. On servers, Node.js can handle other work while it waits for files or network requests.
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?
Frontend developers use JavaScript for interactive pages, and backend developers use it with runtimes such as Node. 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. TypeScript builds on JavaScript, so the two often appear in the same projects.
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?
Old JavaScript tutorials may predate block-scoped variables, promises, native modules, or browser APIs. Check which environment an example targets before copying its workaround.
- 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?
JavaScript is still worth learning if you want to build or maintain JavaScript applications, including code drafted by AI. Agents can 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?
Learn JavaScript first for interactive websites. 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?
Learn frontend JavaScript first to build interactive web pages, or backend JavaScript to build APIs and scripts with Node. Both use the same language, so you can add the other later.
| 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.
Should Beginners Use Node, Deno, or Bun?
Node.js is the best starting point for JavaScript beginners because it has plenty of tutorials and packages. I recommend starting with Node.js and using it for the examples in this guide before trying Deno or Bun. All three are JavaScript runtimes, which let you run JavaScript on your computer or a server without a browser.
| 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.
Choose one runtime while learning. Switching tools will not replace learning variables, functions, and asynchronous code.
Why Does JavaScript Run One Thing at a Time?
Each JavaScript agent executes one job at a time. A browser’s main thread is one example; workers run separately. 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 the current thread, including clicks and typing on a browser’s main thread. Asynchronous APIs let it do other work while waiting, but do not move CPU-heavy JavaScript to another thread. Asynchronous callbacks run later than the code that schedules 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?
Run JavaScript in your browser’s developer console for page experiments, or save a file and run it with Node for scripts outside the browser.
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?
JavaScript does not perform static type checking before execution. 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.
Which JavaScript Guide Should You Read Next?
Read language basics for JavaScript syntax, the DOM guides for page interactions, async for requests and waiting, or Node for scripts outside a browser. Each group below lists its guides 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 canceling 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 You Learn First in JavaScript?
Learn JavaScript values, variables, and functions first, then objects, arrays, and modules. Add DOM events for web pages or Node for scripts, and learn promises when your code needs to wait.
- 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 checking data types would help you maintain the project.
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 You Build First With JavaScript?
For a first JavaScript project, build a small form that validates input and displays a result. 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.
How Does JavaScript Fit With Other Languages?
JavaScript works alongside HTML and CSS on websites. TypeScript adds type checking to JavaScript projects, while Python is an alternative for scripting and data work.
- 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 JavaScript topic should beginners start with?
JavaScript beginners should start with values, variables, and functions, then learn objects, arrays, and modules. Choose DOM guides for web pages or Node guides for scripts outside a browser. Add promises and async/await when your code needs to wait for results.
What is the difference between JavaScript and Java?
JavaScript and Java are different programming languages despite their similar names. Java is statically typed and usually runs on the JVM; JavaScript is dynamically typed and runs in browsers and 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?
You do not need a framework to learn JavaScript. I recommend learning functions, DOM events, and asynchronous code first so you can understand what a framework does for you.
Do you need Node to learn JavaScript?
You do not need Node to learn JavaScript in a browser. Its developer console runs code without installation. Use Node when you want terminal scripts, file access, or project tools outside a web page.
Is JavaScript single-threaded?
Each JavaScript agent executes its jobs on one thread, one job at a time. Workers provide separate agents that can run in parallel, so a JavaScript application can use multiple threads.
Should you learn TypeScript after JavaScript?
Learn TypeScript after you are comfortable with JavaScript if you want type checking for your projects. TypeScript’s type annotations are removed before execution; JavaScript’s runtime behavior still applies.
Should you learn JavaScript or Python first?
Learn JavaScript first for interactive websites, or Python for data analysis and scripting. Both work as first languages. If you have no particular project in mind, I lean toward Python for its gentler first week.
Is JavaScript still worth learning now that AI writes code?
JavaScript is still worth learning when you need to understand, change, or debug JavaScript applications. AI can draft code, but you need language knowledge to check whether it handles errors, data, and user actions correctly.
Is JavaScript hard to learn?
JavaScript’s basics are approachable, and a browser console gives you immediate feedback without installing tools. Equality rules, closures, and asynchronous code take more practice. Work through small examples before combining those topics in a larger project.
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.