Into JavaScript's Cosmos: Syntax, Comments, and Printing

Welcome to our first lesson of the JavaScript introductory course! Today, we will uncover the simplicity and power of JavaScript, a universally esteemed programming language renowned for its expressiveness and readability. We'll learn and practice in the CodeSignal environment, where JavaScript and all its components come pre-installed. By the end of this lesson, you'll grasp the foundational aspects of JavaScript and be able to execute your very first JavaScript code. Intriguing, isn't it?

JavaScript: Syntax Unveiled

Firstly, we'll focus on the essence of JavaScript and its syntax. Every language, whether it's English, Spanish, or JavaScript, operates under a unique syntax. JavaScript, being a language essential to the web, brings interactivity to websites. Its syntax sets the guidelines akin to the rules of English grammar.

Take, for instance, the following JavaScript syntax showcasing code:

This simple line of code, like a basic English sentence, sends out your first JavaScript message: "Hello, JavaScript Universe!".

The Role of Semicolons in JavaScript

In JavaScript, the semicolon (;) acts as a statement terminator, similar to a period in written language. It informs the JavaScript engine that the current statement has concluded, allowing you to start another statement. Here’s a simple analogy for it: just as periods mark the end of sentences in English, semicolons often mark the end of code statements in JavaScript.

Here’s the previous example with an explicit semicolon:

While JavaScript interpreters can often infer where a statement ends even without a semicolon, known as (ASI), it's considered good practice to include them for clarity and to prevent any unforeseen issues, especially in complex scenarios.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal