Syntax

To start your Javascript learning adventure, let’s take a look at the most basic program we can write: A program that prints out the words Hello World

console.log("Hello")

console.log() is one of the most frequently used operations in javascript, and it is used to print out information from our program. It prints whatever lies inside of the brackets. In our case, its the text Hello World. We wrap the text in quotes to indicate that it is text and not code, which in Javascript is called a string.

There are quite a few data types in javascript, but the 3 main ones are numbers, strings, and booleans.

Strings, like the Hello World above, are essentially lines of text, represented by the quotations. Single quotes or double quotes can be used to represent a string.

Numbers are, well, numbers. They can just be written as one would type out a number (ex: 5) Booleans are values that are always true or false. These are represented with the keywords true and false.

The last core concept to understand is code comments, denoted with a //. Comments are for writing things in our file without having our computer think its supposed to be code. Comments are often used to describe what certain code does or provide other background information on the code.

console.log("Hello World")
// Prints the text "Hello World"