Basic Syntax in JavaScript
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!');Output
Hello, World!
Basic Syntax of a JavaScript Program
console.log('Hello, World!');
This line prints the string "Hello, World!" to the console.console.logis 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
Logandlogwould be considered different identifiers. - Comments can be added using
//for single-line comments or/* ... */for multi-line comments.