AI Hints
Home›JavaScript Tutorial›Getting Started
JavaScript · Lesson 2 of 138

Running JavaScript

Node and the browser.

⏱ 2 min read▶ Video at 1:03🎓 Free
Watch this lesson in the JavaScript courseWatch on YouTube ↗Full JavaScript course

There are two easy ways to run JavaScript. In a browser, or with Node dot JS on your computer. We'll use both in this course. Let's start with Node.

Running JavaScript
From the video: Running JavaScript
  • Two ways to run it
  • The browser, or Node
  • We'll use both

Your first program

This file, app dot JS, has one line. Console dot log prints whatever you put inside the brackets. In a terminal, you'd run it by typing node app dot JS. Run it.

app.jsjavascript
console.log("Hello, JavaScript!");
Output
Hello, JavaScript!

Getting set up

To follow along on your own computer, install Node dot JS from nodejs dot org, and a code editor, like Visual Studio Code. Then make a file ending in dot JS, and run it with node, followed by the file name. Or open any browser, press F twelve, and type JavaScript into the console tab.

keyvalue
Node.jsnodejs.org
EditorVS Code
Runnode app.js
BrowserF12, then Console

Summary

Run JavaScript with Node, using node and a file name, or in the browser's console. Next, printing more with console dot log.

Key takeaways
  • node app.js
  • Browser console: F12
  • console.log prints
Next up: console.log — printing output