30 Days of JavaScript: Introduction to JavaScript and Setting Up Your Environment, Day 1

30 Days of JavaScript: Building a Simple Weather App
30 Days of JavaScript: Introduction to JavaScript and Setting Up Your Environment, Day 1

Start your journey into JavaScript development. Explore how this powerful language enhances web experiences on both the client and server side with practical coding examples.

JavaScript is the one language that runs everywhere a web developer works. It powers the button that responds when you click it, the form that catches a typo before you submit, and, since Node.js arrived, the server handling the request behind all of it. Learn it well and you can build the whole stack with a single language. This is Day 1 of 30. Today we cover why JavaScript matters, where it runs, and how to set up a workspace you’ll actually enjoy writing code in.

Table of Contents

Client-Side Power: Bringing Websites to Life

In the browser, JavaScript turns static HTML and CSS into something that reacts. Form validation, image sliders, content that updates without a page reload: all of it runs on JavaScript. It works by reaching into the Document Object Model (the DOM), the browser’s live representation of the page, and changing elements in response to what the user does.

Example: Simple Interactive Webpage

Here’s a small example. The code below finds a button with the ID myButton and listens for a click. When you click it, the button’s background turns blue.

JS
/**
 * Adds an event listener to a button element
 * When the button is clicked, its background color changes to blue
 */
document.getElementById('myButton').addEventListener('click', function() {
    this.style.backgroundColor = 'blue';
});

A few lines, and the page responds to the person using it. That’s the whole idea of client-side JavaScript.

Server-Side: Expanding Horizons with Node.js

For years, JavaScript only ran in the browser. Node.js changed that. It lets you run JavaScript on the server, so the same language handles your front end and your back end: server logic, databases, the lot. That’s what people mean by full-stack JavaScript.

Example: Simple Node.js Server

Here’s a bare HTTP server built with Node. It listens on port 3000 and replies with “Hello, World!” to every request:

JS
/**
 * Creates a simple Node.js server
 * The server listens on port 3000 and responds with "Hello, World!" to any requests
 */
const http = require('http');
const server = http.createServer((req, res) => {
    res.statusCode = 200;
    res.setHeader('Content-Type', 'text/plain');
    res.end('Hello, World!\n');
});
server.listen(3000, () => {
    console.log('Server running at http://127.0.0.1:3000/');
});

No framework, no dependencies. Node gives you a working web server in a dozen lines, and it’s the same JavaScript you just used in the browser.

Setting Up Your Coding Environment

Before we go further, get a good editor in place. This is where you’ll spend your time, so it’s worth picking one you like. Two solid choices:

  • Visual Studio Code (VSCode): Free and open source, built by Microsoft, with strong JavaScript support out of the box. Huge extension library, built-in debugging, and a clean interface. It’s what most JavaScript developers reach for.
  • Sublime Text: Fast and lightweight, with plenty of plugins and deep customization if you want to tune your setup.

Once it’s installed, add a few extensions that pull their weight: auto-completion, a linter to catch mistakes as you type, and an integrated terminal so you’re not switching windows. You don’t need dozens. Start small and add more when you feel the friction.

Using Browser Developer Tools

Every modern browser ships with developer tools, and you’ll live in them. They let you inspect and debug the HTML, CSS, and JavaScript on any page. Chrome, Brave, and Firefox all have excellent ones.

To open them, right-click any page and choose “Inspect”. Or use the keyboard: Ctrl+Shift+I on Windows and Linux, Cmd+Option+I on macOS.

Example: Using the Console

The Console is the part you’ll use first and most. It runs JavaScript right in the browser and shows you the result on the spot, which makes it perfect for testing small snippets.

Open the Console tab, type this, and press Enter:

JS
/**
 * Logs a simple message to the browser console
 */
console.log('Hello, JavaScript!');

You’ll see Hello, JavaScript! print straight back at you. That’s the fastest feedback loop you have while learning, so get used to reaching for it.

Conclusion

That’s the groundwork. You’ve seen where JavaScript runs, in the browser and on the server through Node.js, and how it turns a static page into something that responds to the person using it.

You’ve also got your workspace sorted: an editor you like and the browser dev tools you’ll lean on every day. Getting comfortable with these now pays off fast, because from here on we’re writing and running real code.

What’s Next?

On Day 2 we get into JavaScript’s core syntax: variables, data types, and operators. These are the pieces you’ll use in almost everything you write, so it’s the right place to start building real skill.

Next: 30 Days of JavaScript: JavaScript Syntax and Core Concepts, Day 2

Leave a Comment

Your email address will not be published. Required fields are marked *


Scroll to Top