JavaScript Basic Syntax

JavaScript Basic Syntax

In this tutorial, we will learn the basic syntax of JavaScript language. We will go through the key components of a simple JavaScript program.

JavaScript Program

console.log('Hello, World!');


Hello, World!

Basic Syntax of a JavaScript Program

  1. console.log('Hello, World!');
    This line prints the string "Hello, World!" to the console. console.log is a built-in function in JavaScript for outputting information to the console.

Key Points to Remember

  • All JavaScript statements must end with a semicolon (;), although it is not strictly required and can be omitted in most cases due to automatic semicolon insertion.
  • JavaScript is interpreted by the browser or other runtime environments, and it is case-sensitive, meaning that Log and log would be considered different identifiers.
  • Comments can be added using // for single-line comments or /* ... */ for multi-line comments.