⬅ Previous Topic
What is JavaScript?Next Topic ⮕
JavaScript Hello World Program⬅ Previous Topic
What is JavaScript?Next Topic ⮕
JavaScript Hello World ProgramBefore writing your first line of JavaScript, you need to create the right environment. Think of it like a well-equipped kitchen before you start cooking. This guide will walk you through setting up a JavaScript environment using the browser console, Node.js, and Visual Studio Code (VS Code).
Every modern web browser (Chrome, Firefox, Safari, Edge) has a built-in JavaScript engine. The browser console is the simplest and fastest way to run small snippets of JavaScript.
console.log("Hello from the browser!");
Hello from the browser!
Why use it? It's instant. Great for testing small pieces of code or debugging.
Node.js lets you run JavaScript outside the browser — on your computer, like any other programming language. It's essential for building backend services, running development tools, and testing JavaScript apps.
node -v
npm -v
v20.x.x (or your installed Node version)
10.x.x (npm version)
// Save this as hello.js
console.log("Hello from Node.js");
node hello.js
Hello from Node.js
Pro Tip: You can use node
alone to enter a REPL (interactive shell) for quick tests.
Visual Studio Code is a powerful, lightweight editor with great support for JavaScript. It’s the preferred choice for most developers.
js-learning
app.js
// app.js
let name = "VS Code";
console.log("Running JavaScript in " + name);
node app.js
Running JavaScript in VS Code
Environment | Best For | Pros | Cons |
---|---|---|---|
Browser Console | Quick experiments, DOM testing | No setup, instant access | Not suited for full apps |
Node.js | Backend, tools, scripts | Runs JS anywhere, access to npm | No DOM access |
VS Code | Full development | Powerful editor, extensions | Requires Node for execution |
You now have three solid ways to start writing JavaScript — each serving a unique purpose. Start with the browser for instant feedback, use Node.js for backend or tool development, and adopt VS Code for full-fledged projects. With this setup, you’re ready to dive deeper into the JavaScript universe with confidence.
⬅ Previous Topic
What is JavaScript?Next Topic ⮕
JavaScript Hello World ProgramYou can support this website with a contribution of your choice.
When making a contribution, mention your name, and programguru.org in the message. Your name shall be displayed in the sponsors list.