Your First Program
Discover how to write your first JavaScript program to display a message in the console. Understand the basics of program structure, console commands, and syntax including semicolons. This lesson helps you take the initial step in coding with JavaScript.
We'll cover the following...
Here’s our very first JavaScript program.
This program displays the text "Hello from JavaScript!" in the console, a zone displaying textual information available in most JavaScript environments, such as browsers.
To achieve this, it uses a JavaScript command named console.log(), whose role is to display a piece of information. The text to be displayed is placed between parentheses and followed by a semicolon, which marks the end of the line.
Displaying a text on the screen (the famous Hello World all programmers know) is often the first thing you’ll do when you learn a new programming language. It’s the classic example. You’ve already taken that first step!