Blog
Oct 10, 2025 - 9 MIN READ
Getting Started with JavaScript Using Node.js or Bun

Getting Started with JavaScript Using Node.js or Bun

A beginner-friendly guide to learning JavaScript syntax using modern runtimes like Node.js and Bun — no browser, no DOM, just pure JavaScript.

dogunfx

dogunfx

Most people start learning JavaScript in the browser—interacting with the DOM or clicking buttons on a webpage.
But what if you could learn JavaScript the same way you’d learn Python or Go—running it directly on your computer’s terminal?

That’s where Node.js and Bun come in.
These runtimes let you execute JavaScript outside the browser, helping you focus purely on the language syntax and logic before jumping into web APIs or frontend frameworks.

This post will help you get started running JavaScript locally, writing your first scripts, and learning core syntax fundamentals — all without touching the DOM or setting up a web server.


1. What Are JavaScript Runtimes?

A runtime is what makes JavaScript code actually run.
Browsers like Chrome and Firefox use the V8 engine, but you don’t need a browser to use it.

🟢 Node.js

Node.js uses Google’s V8 engine under the hood, allowing you to run JavaScript from your terminal.
📘 Official Node.js Website

⚡ Bun

Bun is a newer, faster JavaScript runtime built with Zig. It includes a bundler, test runner, and package manager all in one.
📘 Official Bun Website

Both runtimes can execute the same JavaScript syntax — so you can use either one for your learning journey.


2. Installing Node.js or Bun

Install Node.js

Visit nodejs.org and download the LTS version for your OS.
Once installed, verify it:

node -v

Install Bun

On macOS, Linux, or WSL:

curl -fsSL https://bun.sh/install | bash

Then verify:

bun -v

3. Running JavaScript Files

Create a new file called hello.js and add:

console.log("Hello, JavaScript world!");

To run it:

node hello.js

or

bun hello.js

You’ll see the output in your terminal.
That’s it — you’ve just executed your first JavaScript program outside the browser.


4. JavaScript Basics (Syntax Overview)

Let’s look at some key JavaScript building blocks.
You can try each example in your terminal using either Node.js or Bun.

Variables

You can declare variables using let, const, or (older) var.

let name = "Dogunfx";
const age = 25;
var country = "Nigeria";

console.log(name, age, country);
  • let → block-scoped (reassignable)
  • const → block-scoped (not reassignable)
  • var → function-scoped (avoid in modern JS)

Data Types

let isActive = true; // Boolean
let score = 100; // Number
let name = "JavaScript"; // String
let user = { id: 1, name: "Dogunfx" }; // Object
let items = ["Node", "Bun", "Deno"]; // Array

Functions

function greet(name) {
  return `Hello, ${name}!`;
}

console.log(greet("Dogunfx"));

Or using modern arrow functions:

const greet = (name) => `Hello, ${name}!`;
console.log(greet("World"));

Conditionals

let temperature = 30;

if (temperature > 25) {
  console.log("It's hot!");
} else {
  console.log("It's cool!");
}

Loops

const tools = ["Node", "Bun", "Deno"];

for (let tool of tools) {
  console.log(`Runtime: ${tool}`);
}

Objects and Destructuring

const user = { name: "Dogunfx", role: "Developer" };
const { name, role } = user;

console.log(`${name} is a ${role}.`);

Template Literals

let language = "JavaScript";
console.log(`I love coding in ${language}!`);

Arrays and Methods

let numbers = [1, 2, 3, 4, 5];
let doubled = numbers.map((n) => n * 2);

console.log(doubled);

5. Using the REPL (Interactive Mode)

Both Node.js and Bun include a REPL (Read-Eval-Print Loop) — an interactive shell for experimenting with JavaScript.

To start the REPL, type:

node

or

bun repl

You can then type code directly and see results instantly:

> 2 + 3
5
> "Hello".toUpperCase()
"HELLO"

Exit anytime by pressing Ctrl + C twice.


6. Next Steps

Now that you’ve learned how to run JavaScript outside the browser:

  • Practice with functions, loops, and arrays.
  • Explore modules using import and export.
  • Learn about asynchronous programming with Promises and async/await.
  • Try both Node.js and Bun to see which fits your workflow better.

📘 Learn More:


JavaScript is no longer just for browsers — it’s a universal language that runs everywhere.
And with runtimes like Node.js and Bun, the world of pure, fast, backend-friendly JavaScript is just a terminal command away.

Built by DOGUNFX using Nuxt UI • © 2025