Printing and PDF export are disabled for this content. View it online at Full Stack Learning Simplified.
Running JavaScript
There are a few easy ways to run JavaScript while learning β from typing straight into the browser to running files with Node. Pick whichever fits what you're trying to do.
The three main ways
- Browser console β open DevTools (F12) β Console, and type JS live against the current page.
- A
<script>tag β include JS in a web page to add behavior. - Node.js β run a file on your machine with
node app.js(no browser needed).
In a web page
index.html
<!-- external file (preferred) -->
<script src="app.js"></script>
<!-- or inline -->
<script>
console.log("Hello from the page");
</script>Put <script> at the end of <body>, or add defer (<script src="app.js" defer>), so the HTML is parsed before your script runs and the DOM is ready.
With Node.js
bash
# run a file
node app.js
# or an interactive REPL β type JS and see results immediately
nodeQuick experiments
For trying out a snippet, the browser console and the Node REPL are fastest β both evaluate expressions instantly and print the result, with no file or page needed. Online playgrounds (like CodePen or the TypeScript/JS sandboxes) are handy for shareable experiments.
Tip: Use the browser console for anything touching the page (DOM, events), and Node for standalone logic, scripts, and backend code.
console.log() is your constant companion for seeing what's happening. Once comfortable, node app.js and a <script defer> in a page cover the vast majority of real work.Free preview. Sign in and subscribe to unlock all 809 lessons across 25 courses.
Free preview Β· Β© 2026 Full Stack Learning Simplified