⬅ Previous Topic
Introduction to JavaScriptNext Topic ⮕
Writing Your First JavaScript Program⬅ Previous Topic
Introduction to JavaScriptNext Topic ⮕
Writing Your First JavaScript ProgramBefore you start writing JavaScript code, you need a proper environment to run and test your programs. The good news? You don’t need to install any complex tools to get started. A simple web browser and a text editor are enough!
All modern browsers like Chrome, Firefox, Safari, and Edge come with built-in Developer Tools that include a JavaScript Console. This is the easiest way to get started.
console.log("Hello, JavaScript World!");
Output:
Hello, JavaScript World!
Q: Why is this a good starting point?
A: Because it requires no installation and lets you test basic syntax instantly.
If you want to run JavaScript outside the browser (e.g., for backend or automation scripts), Node.js is essential.
Visit the official website: https://nodejs.org and download the LTS version.
node -v
npm -v
Output:
v18.17.0 9.6.7
node
console.log("Node.js is working!");
.exit
Output:
Node.js is working!
Create a file named app.js
with the following code:
console.log("Running from a file");
Run it using:
node app.js
Output:
Running from a file
Visual Studio Code is a lightweight code editor ideal for writing JavaScript.
Visit https://code.visualstudio.com/ and install VS Code.
mkdir js-course
cd js-course
code .
Create a file named index.js
and write:
console.log("Learning JavaScript with VS Code!");
Then run it in terminal:
node index.js
Output:
Learning JavaScript with VS Code!
Q: Why should I use a text editor like VS Code instead of writing code in the browser console?
A: Text editors help you write, manage, and debug larger projects efficiently. They offer syntax highlighting, IntelliSense, version control, and other features that improve productivity.
You can start writing JavaScript with just your browser, but as you grow, it's better to use tools like Node.js and VS Code. This combination prepares you for both frontend and backend JavaScript development.
⬅ Previous Topic
Introduction to JavaScriptNext Topic ⮕
Writing Your First JavaScript 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.